diff --git a/dashboard-plus-chrome-plugin/README.md b/dashboard-plus-chrome-plugin/README.md new file mode 100644 index 0000000..4112b3a --- /dev/null +++ b/dashboard-plus-chrome-plugin/README.md @@ -0,0 +1,22 @@ +Dashboard Plus for the Envato Market +============== + +Dashboard Plus created by @revaxarts + +More details here: http://themeforest.net/forums/thread/introducing-dashboard-plus/71870 + +Install from the Webstore: https://chrome.google.com/webstore/detail/dashboard-plus-for-envato/gcbcdaghonmljaplbpbbimmmfhmhcheh + +Development Howto: +------------- + +1. Fork a copy of this repo +2. Checkout your copy of the repo to your local computer +3. Uncomment the `//var dashboardplus_base_uri = chrome.extension.getURL('');` code in `script.js` so files are loaded locally. +3. Disable the real Dashboard Plus extension in Google Chrome +4. Click "Developer Mode" at the top of the Google Chrome extension page +5. Click "Load Unpacked Extension" and select the git checkout folder +6. This should load your own local copy of the extension into Google Chrome +7. Edit the files and use the "Reload" button on the Extension page to test the changes. +8. Once happy with changes, commit them back to your git repo, then do a pull request so I can merge those changes into this repo for everyone. + diff --git a/dashboard-plus-chrome-plugin/bootstrap.js b/dashboard-plus-chrome-plugin/bootstrap.js new file mode 100644 index 0000000..1606f66 --- /dev/null +++ b/dashboard-plus-chrome-plugin/bootstrap.js @@ -0,0 +1,476 @@ +/* + * Copyright (c) 2014 + * ================================== + * powered by revaxarts.com (http://revaxarts.com) + * original filename: bootstrap.js + * filesize: 12643 Bytes + * last modified: Thu, 12 Jun 2014 09:12:30 +0200 + * + */ +(function () { + + //"use strict" + + var version = '1.5', + cookiePrefix = 'dbp_'; + + if( typeof jQuery != 'undefined' ){ + go(); + return; + } + + yepnope({ + load: [ + "http://0.envato-static.com/assets/application/vendor-2b538c3f97134712a085fc58f4c396f5.js" + ], + complete: go + }); + + function go(){ + + var username = $('.global-header-menu__link-text').html(); + var loadit = []; + var storage; + if(!username) return false; + window.dashboardplus = window.dashboardplus || {}; + window.dashboardplus['base'] = window.dashboardplus['base'] || '//dtbaker.github.io/dashboard-plus/'; + window.dashboardplus['user'] = username; + + try{ + window.dashboardplus['storage'] = $.parseJSON(localStorage.getItem('dashboardplus')); + + if(!window.dashboardplus['storage']) { + window.dashboardplus['storage'] = {}; + + save('firstvisit', true); + if(confirm('Welcome to Dashboard Plus!\nYou have to enable plugins at the settings page!\n\nGo there?')){ + location.href = '/user/'+username+'/edit#dashboard_plus'; + } + } + + }catch (e) { + window.dashboardplus['storage'] = {}; + } + + window.dashboardplus.set = function(extension, name, value){ + var obj = localStorage[extension] ? $.parseJSON(localStorage[extension]) : {}; + + obj[name] = value; + localStorage.setItem(extension, JSON.stringify(obj)); + + }; + + window.dashboardplus.get = function(extension, name){ + var obj = localStorage[extension] || false; + + if(!obj) return ''; + + obj = $.parseJSON(obj); + + return (obj[name]) ? obj[name] : ''; + }; + + window.dashboardplus.delete = function(extension, name){ + if(!name){ + localStorage.removeItem(extension); + }else{ + var obj = localStorage[extension] ? $.parseJSON(localStorage[extension]) : {}; + if(obj[name]){ + delete(obj[name]); + localStorage.setItem(extension, JSON.stringify(obj)); + } + } + + }; + + window.dashboardplus.setCookie = function(cookieName, value, daysToExpire, path, domain, secure) { + var expiryDate; + + cookieName = cookiePrefix + cookieName; + + if (daysToExpire) { + expiryDate = new Date(); + expiryDate.setTime(expiryDate.getTime() + (daysToExpire * 8.64e7)); + } + + document.cookie = cookieName + '=' + (value.toString()) + + (daysToExpire ? ';expires=' + expiryDate.toGMTString() : '') + + ';path=' + (path ? path : '/') + + (domain ? ';domain=' + domain : '') + + (secure ? ';secure' : ''); + return window.dashboardplus.getCookie(cookieName); + }; + + window.dashboardplus.getCookie = function(cookieName) { + + cookieName = cookiePrefix + cookieName; + + var cookiePattern = new RegExp('(^|;)[ ]*' + cookieName + '=([^;]*)'), + cookieMatch = cookiePattern.exec(document.cookie); + if(cookieMatch){ + return cookieMatch[2]; + } + return 0; + }; + + window.dashboardplus.deleteCookie = function(cookieName) { + return window.dashboardplus.setCookie(cookieName, 0, -1); + }; + + var fontawesome = $(''); + + var active_plugins = get('active', {}); + + var $content = $('#content'); + + var plugins = { + 'statementer': { + 'name': 'Statementer', + 'desc': 'Advanced Statement Section (graphs etc..)' + }, + 'statement_merge': { + 'name': 'Statement Merge', + 'desc': 'Merge author fees into a single row on the statement page' + }, + 'notification': { + 'name': 'Notifications', + 'desc': 'Display count of unread item comments' + }, + 'reminder': { + 'name': 'Withdrawal reminder', + 'desc': 'never forget to withdraw your earned money!', + 'settings':[ + { + 'id': 'hours', + 'label': 'define the hours you would like to get reminded before deadline', + 'placeholder': '1, 3, 24, 48, 72' + } + ] + }, + 'editinline': { + 'name': 'Edit Inline (currenlty disabled)', + 'desc': 'Edit your items directly on the item description page' + }, + 'envatitor': { + 'name': 'Envatitor Embedded', + 'desc': 'Advanced editor for the forums', + 'font': true + }, + 'verify': { + 'name': 'Purchase Verification', + 'desc': 'verify purchasecodes right on your dashboards sidebar' + }, + 'progressbar': { + 'name': 'Upload Progressbar', + 'desc': 'Show the progressbar on uploads' + }, + 'quickcollection': { + 'name': 'Quickcollection', + 'desc': 'Add items to your bookmarks from the item thumbnail' + }, + 'gotolivepreview': { + 'name': 'GoToLivepreview', + 'desc': 'open livepreview right from the item thumbnail (only CC, TF, AD)' + }, + 'chaching': { + 'name': 'Cha-Ching for Envato Authors', + 'desc': 'Sales Notification with sound!', + 'settings':[ + { + 'id': 'playsound', + 'type': 'checkbox', + 'label': 'play sound' + } + ] + }, + // 'salesrefresher': { + // 'name': 'Sales Refresher', + // 'desc': 'Refresh your salescount without reloading the site (click on your balance to reload)', + // 'settings':[ + // { + // 'id': 'autoreload', + // 'type': 'checkbox', + // 'label': 'autoreload every 5 minutes' + // } + // ] + // }, + 'replypantry': { + 'name': 'Reply Pantry', + 'desc': 'Store canned text for use in forums and item comments' + }, + 'compare_earnings': { + 'name': 'Compare Earnings', + 'desc': 'allows you to compare your earnings with a previous month/year' + }, + '_localdevelopment': { + 'beta': true, + 'name': 'Local Development', + 'desc': 'development only' + } + }; + + //Dashboard Page + if (location.href.match(/^https?:\/\/([\.a-z3]+)\.(net)\/author_dashboard/)) { + + enque('envatitor'); + enque('verify'); + enque('progressbar'); + enque('replypantry'); + + //Earnings Page + }else if (location.href.match(/^https?:\/\/([\.a-z3]+)\.(net)\/user\/(\w+)\/earnings\/(total_sales|item_sales|referrals|support_sales)\/(.*)/)) { + + enque('compare_earnings'); + + //Settings Page + }else if (window.location.href.match(/^https?:\/\/[\.a-z3]+\.net\/user\/.*\/statement/) || location.href.match(/^https?:\/\/([\.a-z3]+)\.(net)\/statement/)) { + + enque('statementer'); + enque('statement_merge'); + + //Forums Page + }else if (location.href.match(/^https?:\/\/([\.a-z3]+)\.(net)\/user\/([\w-]+)\/(\w+)/)) { + + settingspage(); + + //Statement Page + }else if (location.href.match(/^https?:\/\/([\.a-z3]+)\.(net)\/forums\//)) { + + enque('envatitor'); + enque('replypantry'); + //Upload Page + }else if (location.href.match(/^https?:\/\/([\.a-z3]+)\.(net)\/upload\//)) { + + enque('envatitor'); + + //item edit page + }else if (location.href.match(/^https?:\/\/([\.a-z3]+)\.(net)\/item\/([a-z0-9-]+)\/edit/)) { + + enque('envatitor'); + + //item discussion page + }else if (location.href.match(/^https?:\/\/([\.a-z3]+)\.(net)\/item\/([a-z0-9-]+)\/discussion/)) { + + enque('envatitor'); + enque('replypantry'); + + //item discussion page + }else if (location.href.match(/^https?:\/\/([\.a-z3]+)\.(net)\/item\/([a-z0-9-]+)\/([0-9]+)\/comments/)) { + + enque('envatitor'); + enque('replypantry'); + + //item faq page + }else if (location.href.match(/^https?:\/\/([\.a-z3]+)\.(net)\/item\/([a-z0-9-]+)\/([0-9]+)\/faqs/)) { + + enque('envatitor'); + + //item discussion page + } + + if (location.href.match(/^https?:\/\/(themeforest|codecanyon|activeden)\.net/)) { + + enque('gotolivepreview'); + + } + + if (location.href.match(/^https?:\/\/([\.a-z3]+)\.(net)\/item\/([a-z0-9-]+)/)) { + + //enque('editinline'); + + } + //everywhere; + enque('notification'); + enque('quickcollection'); + enque('chaching'); + // enque('salesrefresher'); + enque('reminder'); + + enque('_localdevelopment'); + + + load(function(){ + console.log('Thanks for using Dashboard Plus!'); + }); + + + function enque(plugin){ + + if(!plugin || !active_plugins[plugin] || !plugins[plugin]) return false; + + loadit.push(plugin); + if(plugins[plugin].font || plugin == '_localdevelopment'){ + fontawesome.appendTo('head'); + } + + delete active_plugins[plugin]; + + } + + function load(callback){ + + if(!loadit.length) return false; + + loadit.sort(); + var url = window.dashboardplus['base']+'plugins/'; + + var script_count = 0; + for(var item in loadit){ + script_count++; + console.log(plugins[loadit[item]].name+' loaded!'); + var plugin_url = url + loadit[item] + '.js?v=' + version; + + console.log("Loading script: "+script_count + " url: " + plugin_url); + $.ajax({ + url: plugin_url, + dataType: "script", + success: function(){ + script_count--; + console.log("Left to load: "+script_count); + if(script_count<=0){ + // we've loaded all scripts completely... run our callback + callback(); + } + }, + cache: true + }); + } + + + } + + + function settingspage(){ + + var active = (location.hash == '#dashboard_plus') ? ' active' : ''; + + $content.find('.side-tabs').append('
  • Dashboard Plus
  • '); + + var boxhtml = '

    Dashboard Plus

    Select all features you would like to activate. Please check out the forum thread if you have questions

    Available Plugins

    '; + + $.each(plugins, function(id, data){ + + if(!(typeof data.beta != 'undefined' && !(username == 'revaxarts'))){ + + boxhtml += '
    '; + + if(data.settings){ + $.each(data.settings, function (i, setting){ + if(!setting.type) setting.type = 'textfield'; + if(!setting.placeholder) setting.placeholder = ''; + + boxhtml += '
    '; + switch(setting.type){ + case 'checkbox': + boxhtml += ''; + break; + case 'textfield': + default: + boxhtml += ''+setting.label+' '; + break; + + } + boxhtml += '
    '; + + }); + } + + boxhtml += '
    '; + } + + }); + + boxhtml += '
    buy me a beer
    '; + + $('#dashboard_plus_link').click(function(){ + + $content.find('.content-s').html(boxhtml); + + $content.find('.layout__sidebar').find('a').removeClass('active'); + + $(this).addClass('active'); + + $('#dashboardplus_form').on('submit', function(){ + + var data = {}; + var setting = {}; + $.each($('.dbp_plugins'), function(){ + + if($(this).is(':checked')) data[$(this).val()] = true; + + }); + $.each($('.dbp_setting'), function(){ + var id = $(this).data('id'); + if(!setting[id]) setting[id] = {}; + + setting[id][$(this).data('name')] = ($(this).is(':checkbox') ? $(this).is(':checked') : $(this).val()); + + }); + + $.each(setting, function(extension, data){ + savesettings(extension, data); + }); + + if(save('active', data)) location.reload(); + + return false; + + }); + + $('#dbp_reset_button').on('click', function(){ + if(confirm('Do you really like ti reset all Dashboard Plus settings?\n\n This is only for the current marketplace!')){ + var storage = ['apikey', 'chaching', 'dashboardplus', 'quickcollection', 'ratings__', 'reminder', 'salesrefresher', 'statementer']; + var cookies = ['envatitor_badges', 'envatitor_thumb', 'notification_count', 'notification_lastcheck', 'quickcollection_lastcheck', 'statementer_lastbalance']; + + $.each(storage, function(i,e){ + console.log(e, i); + localStorage.removeItem(e); + }); + $.each(cookies, function(i,e){ + console.log(e, i); + window.dashboardplus.deleteCookie(e); + }); + + location.reload(); + + } + return false; + }); + + return false; + + + }); + + if(active == ' active') $('#dashboard_plus_link').trigger('click'); + + + } + + function savesettings(extension, data){ + $.each(data, function(name, value){ + window.dashboardplus.set(extension, name, value); + }); + } + + + function save(setting, value){ + var settings = window.dashboardplus.storage || {}; + + settings[setting] = value; + + localStorage.setItem('dashboardplus', JSON.stringify(settings)); + + window.dashboardplus.storage = settings; + + return window.dashboardplus.storage[setting] == value; + + } + + function get(setting, fallback){ + return window.dashboardplus.storage[setting] ? window.dashboardplus.storage[setting] : fallback; + } + + } + +})(); diff --git a/dashboard-plus-chrome-plugin/changelog.txt b/dashboard-plus-chrome-plugin/changelog.txt new file mode 100644 index 0000000..696a8da --- /dev/null +++ b/dashboard-plus-chrome-plugin/changelog.txt @@ -0,0 +1,64 @@ + + +2019.06.28 - version 1.4.9 + * Source files from local plugin install + * Statement CSV change (Thanks Ataurr) + +2017.07.02 - version 1.4.8 + * Statement CSV change (AU GST Added) + +2017.01.26 - version 1.4.7 + * Statement CSV change + +2016.09.13 - version 1.4.6 + * Statement CSV change + +2016.07.07 - version 1.4.4 + * SSL fixes + +2016.01.06 - version 1.4.3 + * Merge statement rows + +2016.01.04 - version 1.4.2 + * Fix for new US tax + +2015.09.09 - version 1.4.1 + * Fix for duplicate extended support sales + +2015.09.04 - version 1.4.0 + * Fix for new statement CSV format and extended support stats + +2015.04.16 - version 1.3.9 + * URL Change in Profile Page + +2015.03.27 - version 1.3.8 + * URL Change in Profile Page + +2015.03.18 - version 1.3.7 + * Sales Location Map Added To Statementer + +2015.03.18 - version 1.3.6 + * Statement CSV fix + +2014.12.19 - version 1.3.5 + * Statement CSV fix + +2014.08.28 - version 1.3.4 + * Progress bar on uploads + +2014.08.27 - version 1.3.3 + * Reply Pantry added + * Fix for author names with -_ chars in them + +2014.08.27 - version 1.3.2 + * Added top secret progress bar plugin + +2014.08.26 - version 1.3.1 + * Fix in manifest.json for Chrome Webstore + +2014.08.26 - version 1.3.0 + * Changing script sources to host js files from Github pages instead of @revaxarts hosting + * Adjust manifest.json to support Chrome Webstore submission + +2014.08.26 - version 1.2.0 + * Initial import of plugin from @revaxarts \ No newline at end of file diff --git a/dashboard-plus-chrome-plugin/css/envato-style.css b/dashboard-plus-chrome-plugin/css/envato-style.css new file mode 100644 index 0000000..9360a53 --- /dev/null +++ b/dashboard-plus-chrome-plugin/css/envato-style.css @@ -0,0 +1,10 @@ +/* + * Copyright (c) 2014 + * ================================== + * powered by revaxarts.com (http://revaxarts.com) + * original filename: envato-style.css + * filesize: 4061 Bytes + * last modified: Tue, 07 May 2013 16:16:10 +0200 + * + */ +html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td { margin:0; padding:0; border:0; outline:0; font-weight:inherit; font-style:inherit; font-size:100%; font-family:inherit; vertical-align:baseline; } :focus { outline:0; } body { overflow:hidden; font-family:Tahoma,Geneva,sans-serif; font-size:13px; line-height:18px; background:#D2D1D0; color:#444; border:0 !important; padding: 0 0 0 20px; } a,a:visited { color:#8A6741; cursor:pointer; text-decoration:none; } a:hover { text-decoration:underline; } body.activeden a { color:#B85D04!important; } body.audiojungle a { color:#547F23!important; } body.themeforest a { color:#8A6741!important; } body.videohive a { color:#B27723!important; } body.graphicriver a { color:#006AB7!important; } body.threedocean a { color:#990D2c!important; } body.codecanyon a { color:#BC3415!important; } body.tutorials a { color:#B85D04!important; } body.photodune a { color:#20929A!important; } h1 { display:none; } h2,h3,h4,h5,h6 { padding-left:1px; padding:20px 0 15px; color:#191919; line-height:normal; } h2 { color:#000; margin-top:20px; padding-bottom:10px; margin-bottom:15px; border-bottom:1px solid #bfbebe; box-shadow:0 2px 0 -1px #ededed; font-size:20px; font-size: 27px; line-height:35px; } h3 { margin-top:20px; padding-bottom:10px; margin-bottom:15px; border-bottom:1px solid #bfbebe; box-shadow:0 2px 0 -1px #ededed; font-size:18px; font-size:24px; line-height: normal; color:#605d57; } h4 { color:#000; font-family:sans-serif; font-size:16px; font-weight:700; text-transform:uppercase; margin-top:15px; } h5 { font-size:17px; } h6 { } hr { display:block; background-color:#bfbebe; border-color:#ededed; border-style:solid; border-width:0 0 1px; height:1px; margin-top:15px; margin-bottom:15px; } p { margin-bottom:20px; padding:0; } p:last-child { margin-bottom:0; } small { color:#909090; font-size:11px; } ol,ul { margin-bottom:20px; padding-left:25px; } ol { list-style-type:decimal; } ul { list-style:disc; } table { margin-bottom:20px; max-width:100%; max-width: 616px; overflow:auto; } img { max-width:100%; } blockquote { border-left:1px solid #423021; color:#777; font-family:"Helvetica Neue",Helvetica,Arial,sans-serif; font-style:italic; margin-bottom:20px; padding-left:20px; } body.activeden blockquote { border-left-color:#B85D04!important; } body.audiojungle blockquote { border-left-color:#547F23!important; } body.themeforest blockquote { border-left-color:#8A6741!important; } body.videohive blockquote { border-left-color:#B27723!important; } body.graphicriver blockquote { border-left-color:#006AB7!important; } body.threedocean blockquote { border-left-color:#990D2c!important; } body.codecanyon blockquote { border-left-color:#BC3415!important; } body.tutorials blockquote { border-left-color:#B85D04!important; } body.photodune blockquote { border-left-color:#20929A!important; } pre { margin-bottom:20px; } h2,h3,h4,h5,h6 { margin:30px 0 20px; padding:0; } h2:first-child,h3:first-child,h4:first-child,h5:first-child,h6:first-child { margin-top:0; } h1 { display:none; } h2 { border-bottom:1px solid #bfbebe; box-shadow:0 2px 0 -1px #ededed; font-size:20px; line-height:30px; padding-bottom:10px; } h3 { border-bottom:1px solid #bfbebe; box-shadow:0 2px 0 -1px #ededed; font-size:18px; line-height:27px; color:#605d57; padding-bottom:10px; } h4 { font-size:16px; line-height:24px; font-weight:700; text-transform:uppercase; } em{ font-style: italic; } strong{ font-weight: 700; } body table:hover td,body table:hover th,body ul:hover,body ol:hover,body p:hover,body dl:hover,body img:hover,body h2:hover,body h3:hover,body h4:hover,body h5:hover { border-raduis:3px; box-shadow:0 0 3px rgba(0,0,0,0.3); } \ No newline at end of file diff --git a/dashboard-plus-chrome-plugin/css/jquery.wysiwyg.css b/dashboard-plus-chrome-plugin/css/jquery.wysiwyg.css new file mode 100644 index 0000000..5dbc2e7 --- /dev/null +++ b/dashboard-plus-chrome-plugin/css/jquery.wysiwyg.css @@ -0,0 +1,10 @@ +/* + * Copyright (c) 2014 + * ================================== + * powered by revaxarts.com (http://revaxarts.com) + * original filename: jquery.wysiwyg.css + * filesize: 7243 Bytes + * last modified: Thu, 16 May 2013 17:59:28 +0200 + * + */ +#overlay{ position: fixed; top: 0; right: 0; left: 0; bottom: 0; background: #000; z-index: 10; } #info_box{ position: absolute; z-index: 15; background:#F4F4F4; border: 1px solid #BBB; padding: 20px; } #info_box.fixed{ position: fixed; } #item_description_content{ position: relative; z-index: 11; margin: 0 -20px; resize:vertical; } div.wysiwyg { position: relative; z-index: 15; margin: 0 -20px; min-width: 654px; } div.wysiwyg * { margin:0; padding:0; } div.wysiwyg ul.toolbar li.jwysiwyg-custom-command { overflow:hidden; } div.wysiwyg ul.toolbar { float:left; margin-top: 20px; background:#F4F4F4; width: 648px; z-index: 2; border: 1px solid #BBB; padding: 2px; } div.wysiwyg ul.toolbar.fixed { position: fixed; top: 20px; } div.wysiwyg ul.toolbar li { list-style:none; float:left; margin:4px 2px 4px 0; background:#f0f0f0; -moz-user-select:none; -webkit-user-select:none; user-select:none; clear:none; padding:0; } div.wysiwyg ul.toolbar li:hover { } div.wysiwyg ul.toolbar li.separator { background:none; width:1px; height:26px; margin:0 4px 0 5px; border:none; border-left:1px solid #ccc; } div.wysiwyg ul.toolbar li { text-indent:-5000px; display:block; width:18px; height:18px; background:url(http://i.imgur.com/cNKL9uV.gif) no-repeat -640px -800px; border:1px solid transparent; cursor:pointer; margin:0 2px; } div.wysiwyg ul.toolbar li.wysiwyg-button-hover,div.wysiwyg ul.toolbar li.active { background-color: #c1c1c1; border:1px solid transparent; } div.wysiwyg ul.toolbar li.active { background-color: #c1c1c1; } div.wysiwyg ul.toolbar li.disabled,div.wysiwyg ul.toolbar li.wysiwyg-button-hover.disabled,div.wysiwyg ul.toolbar li.active.disabled { opacity:.5; filter:alpha(opacity=50); cursor:auto; } div.wysiwyg ul.toolbar li.bold { background-position: -1px -15px; } div.wysiwyg ul.toolbar li.italic { background-position: -18px -15px; } div.wysiwyg ul.toolbar li.strikeThrough { background-position: -36px -15px; } div.wysiwyg ul.toolbar li.underline { background-position: -55px -15px; } div.wysiwyg ul.toolbar li.highlight { background-position: -48px -96px; } div.wysiwyg ul.toolbar li.justifyLeft { background-position: 0 2px; } div.wysiwyg ul.toolbar li.justifyCenter { background-position: -18px 2px; } div.wysiwyg ul.toolbar li.justifyRight { background-position: -36px 2px; } div.wysiwyg ul.toolbar li.justifyFull { background-position: -55px 2px; } div.wysiwyg ul.toolbar li.indent { background-position: -74px 1px; } div.wysiwyg ul.toolbar li.outdent { background-position: -92px 1px; } div.wysiwyg ul.toolbar li.subscript { background-position: -74px -15px; } div.wysiwyg ul.toolbar li.superscript { background-position: -92px -15px; } div.wysiwyg ul.toolbar li.undo { background-position: 0px -68px; } div.wysiwyg ul.toolbar li.redo { background-position: -18px -69px; } div.wysiwyg ul.toolbar li.insertOrderedList { background-position: -36px -49px; } div.wysiwyg ul.toolbar li.insertUnorderedList { background-position: -19px -49px; } div.wysiwyg ul.toolbar li.insertHorizontalRule { background-position: 0 -49px; } div.wysiwyg ul.toolbar li.h1 { background-position: 0px -31px; } div.wysiwyg ul.toolbar li.h2 { background-position: -18px -31px; } div.wysiwyg ul.toolbar li.h3 { background-position: -36px -31px; } div.wysiwyg ul.toolbar li.h4 { background-position: -55px -31px; } div.wysiwyg ul.toolbar li.h5 { background-position: -74px -31px; } div.wysiwyg ul.toolbar li.h6 { background-position: -92px -31px; } div.wysiwyg ul.toolbar li.paragraph { background-position: 0px -106px; } div.wysiwyg ul.toolbar li.colorpicker { background-position: -18px -106px; } div.wysiwyg ul.toolbar li.fullscreen { background-position: -36px -106px; } div.wysiwyg ul.toolbar li.cut { background-position: -36px -68px; } div.wysiwyg ul.toolbar li.copy { background-position: -55px -68px; } div.wysiwyg ul.toolbar li.paste { background-position: -74px -68px; } div.wysiwyg ul.toolbar li.insertTable { background-position: -74px -49px; } div.wysiwyg ul.toolbar li.increaseFontSize { background-position: -18px -87px; } div.wysiwyg ul.toolbar li.decreaseFontSize { background-position: -36px -87px; } div.wysiwyg ul.toolbar li.createLink { background-position: -92px -48px; } div.wysiwyg ul.toolbar li.unLink { background-position: -74px -87px; } div.wysiwyg ul.toolbar li.insertImage { background-position: -92px -87px; } div.wysiwyg ul.toolbar li.html { background-position: -55px -49px; } div.wysiwyg ul.toolbar li.removeFormat { background-position: -92px -68px; } div.wysiwyg ul.toolbar li.empty { background-position: -73px -86px; } div.wysiwyg ul.toolbar li.code { background-position: -74px -106px; } div.wysiwyg ul.toolbar li.cssWrap { background-position: -92px -106px; } div.wysiwyg-dialogRow { float:left; width:100%; font-size:16px; } div.wysiwyg iframe { clear:left; background-color:#fff; padding:0; margin:0; display:block; width:100%; min-width: 654px; } .wysiwyg-dialog { position:fixed; top:50px; left:50px; width:450px; height:300px; background:transparent; font:14px "Helvetic Neue",Helvetica,Arial,sans-serif; } .wysiwyg-dialog .wysiwyg-dialog-topbar { background:#333; border:1px #111 solid; color:#fff; padding:10px; position:relative; } .wysiwyg-dialog .wysiwyg-dialog-topbar .wysiwyg-dialog-close-wrapper .wysiwyg-dialog-close-button { color:#fff; text-decoration:none; display:block; padding:6px 10px; position:absolute; right:12px; top:50%; height:14px; margin-top:-12px; } .wysiwyg-dialog .wysiwyg-dialog-topbar .wysiwyg-dialog-close-wrapper a.wysiwyg-dialog-close-button:hover { background:#666; } .wysiwyg-dialog .wysiwyg-dialog-topbar .wysiwyg-dialog-title { font-size:20px; font-weight:700; padding:5px; } .wysiwyg-dialog .wysiwyg-dialog-content { border:1px #ccc solid; border-top:0; padding:15px; background:#fff; } .wysiwyg-dialog-modal-div { position:absolute; top:0; left:0; width:100%; height:100%; background-color:#fff; background-color:rgba(0,0,0,0.5); filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000,endColorstr=#99000000); -ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000,endColorstr=#99000000)"; } .wysiwyg-dialog-content form.wysiwyg fieldset { border:1px #ccc solid; } .wysiwyg-dialog-content form.wysiwyg legend { padding:7px; } .wysiwyg-dialog-content form.wysiwyg .form-row { clear:both; padding:4px 0; } .wysiwyg-dialog-content form.wysiwyg .form-row label,.wysiwyg-dialog form.wysiwyg .form-row .form-row-key { display:block; float:left; width:35%; text-align:right; padding:4px 5px; } .wysiwyg-dialog-content form.wysiwyg .form-row .form-row-value { display:block; float:left; width:55%; } .wysiwyg-dialog-content form.wysiwyg .form-row input.width-auto { width:auto; } .wysiwyg-dialog-content form.wysiwyg input.width-small { width:50px; min-width:50px; max-width:50px; } .wysiwyg-dialog-content form.wysiwyg input,.wysiwyg-dialog form.wysiwyg select { padding:2px; width:100%; margin:2px; } .wysiwyg-dialog-content form.wysiwyg input[type=submit],.wysiwyg-dialog form.wysiwyg input[type=reset] { padding:2px 7px; width:auto; } \ No newline at end of file diff --git a/dashboard-plus-chrome-plugin/css/replypantry.css b/dashboard-plus-chrome-plugin/css/replypantry.css new file mode 100644 index 0000000..57fd4c5 --- /dev/null +++ b/dashboard-plus-chrome-plugin/css/replypantry.css @@ -0,0 +1,233 @@ +#cancontainer{ + position:relative; + width:200px; + z-index:100; +} +#cancontents{ + + width:200px; + + -webkit-border-radius:2px; + border:1px solid #fff; + + z-index:10; +} +#cancontainer #cancontents ul li{ + padding:7px 10px; + margin:0 !important; + position:relative; + border-top:1px solid #191919; + box-shadow:inset 0px 1px 1px rgba(255, 255, 255, .1); + + background:#222; + background:#bbb -webkit-linear-gradient(bottom, rgba(0,0,0,.87) 50%, rgba(0,0,0, .85)); +} +#cancontainer #cancontents ul li:first-child{ + border-radius:2px 2px 0 0 ; +} +#cancontainer #cancontents ul li:last-child{ + border-radius:0 0 2px 2px; +} +#cancontainer #cancontents ul li:hover{ + background:#bbb -webkit-linear-gradient(bottom, rgba(0,0,0,.97) 50%, rgba(0,0,0, .95)); +} +#cancontainer #cancontents ul li a{ + color:#f5f5f5; + text-shadow:0px -1px 1px #000; + display:block; + margin:0 !important; + text-transform:none; + font-size:12px; +} +#cancontainer #cancontents ul li a:hover{ + text-decoration:none; +} +#cancontainer #cancontents ul li a img{ + padding:0; +} +#cancontainer.item-comments{ + position: absolute; + width: 200px; + z-index: 100; + bottom: 40px; +} +#canbutton{ + position:relative; + margin:0; +} +#canbutton img{ + padding:0; +} +.cantip{ + width: 0; + height: 0; + border-left: 10px solid transparent; + border-right: 10px solid transparent; + + border-top: 10px solid #191919; + + position:absolute; + top:98%; + left:14px; + + z-index:20; +} + +.cankey-edit{ + position:absolute; + right:8px; + top:8px; + +} + +.cankey-editor{ + position:absolute; + left:100%; + bottom:1px; + display:none; + + padding:7px 10px; + border-top:1px solid #191919; + box-shadow:inset 0px 1px 1px rgba(255, 255, 255, .1); + + background:#222; + background:#bbb -webkit-linear-gradient(bottom, rgba(0,0,0,.87) 50%, rgba(0,0,0, .85)); + + border-top:1px solid #191919; + box-shadow:inset 0px 1px 1px rgba(255, 255, 255, .1); + + border-radius:2px; +} + +.cankey-editor textarea{ + padding:8px !important; + width:300px !important; + max-height:100px; + display:block; + border-radius:0; + margin-bottom:10px; +} +.cankey-editor input[type='text']{ + padding:8px !important; + width:280px !important; + -webkit-transition: all .2s ease-in-out; + border-radius:0; + + float:left; + margin-bottom:5px; +} +.cankey-editor input[type='text']:not(:focus){ + background: transparent; + border: none; + padding-left: 0px !important; + margin-top:0px; + /*padding-top: 0px !important;*/ + color: white; + font-style: normal; + font-weight: bold; +} + +.cankey-editor select#cankey-editor-cat{ + width:auto !important; + display:block; + float:left; + border-radius:0; +} +.cankey-editor input[type="submit"]{ + float:right; + margin-right:0; + background-color: #EF452C; + background-image: -webkit-linear-gradient(top, rgba(255, 255, 255, .2) 0%,rgba(0, 0, 0, .2) 100%), url('http://0.envato-static.com/images/buttons-8a861acb09.png'); + background-position: top left, 93% -735px; + background-repeat: repeat, no-repeat; + box-shadow:inset 0px 1px 1px rgba(255,255,255,.3); + text-shadow:0px -1px 1px rgba(0, 0, 0, .2); + border: 1px solid #901B09; + border-top-color: #B23D2B; + border-left-color: #B23D2B; + margin-top:3px; +} + +#can-close-editor{ + color:#fff; + text-decoration:none; + /*position: absolute; + right: 5px; + bottom: 5px;*/ + float:right; +} + +.cankey-remove{ + position:absolute; + top:3px; + right:25px; + padding:5px; +} + +#canpanel{ + display:none; + position:absolute; + bottom:125%; + left:-12px; +} + +.can-buttons{ + +} +.can-buttons a{ + display:inline-block; + margin:0px 2px 2px 1px !important; + padding:3px 5px; + border:1px solid #999; + border-radius:2px; + box-shadow:inset 0px 1px 1px rgba(255, 255, 255, .3); + + background:#666; + background:#aaa -webkit-linear-gradient(bottom, rgba(200,200,200,1) 50%, rgba(180,180,180, .5)); + + color:#222; + text-shadow:0px 1px 1px #eee; + font-size:10px; + text-transform:none; +} + +.can-buttons a:hover{ + text-decoration:none !important; +} + +#can-new{ + float:right; + background:#ef452c -webkit-linear-gradient(top, rgba(255,255,255,.2) 0%,rgba(0,0,0,.2) 100%); /* Chrome10+,Safari5.1+ */ + border:1px solid #901B09; + border-top-color:#B23D2B; + border-left-color:#B23D2B; + + box-shadow:inset 0px 1px 1px rgba(255,255,255,.3); + text-shadow:0px -1px 1px rgba(0, 0, 0, .2); + color:#fff; +} + +.can-keyname{ + padding-right:40px; +} + +#canlist{ + max-height: 300px; + overflow-y: auto; + overflow-x: hidden; + margin:0px !important; +} + +.cankey-op .cantext{ + display:none; +} + +#can_previewbox{ + display:none; + width:200px; +} +#can_previewbox textarea{ + border:none; + font-family:Arial, Helvetica, sans-serif; +} + diff --git a/dashboard-plus-chrome-plugin/css/statement_merge.css b/dashboard-plus-chrome-plugin/css/statement_merge.css new file mode 100644 index 0000000..71c8478 --- /dev/null +++ b/dashboard-plus-chrome-plugin/css/statement_merge.css @@ -0,0 +1,4 @@ + +.statement_row_hidden td{ + background-color:#FFCECE !important; +} \ No newline at end of file diff --git a/dashboard-plus-chrome-plugin/css/statementer.css b/dashboard-plus-chrome-plugin/css/statementer.css new file mode 100644 index 0000000..2277dc4 --- /dev/null +++ b/dashboard-plus-chrome-plugin/css/statementer.css @@ -0,0 +1,396 @@ +/* + * Copyright (c) 2014 + * ================================== + * powered by revaxarts.com (http://revaxarts.com) + * original filename: statementer-2.1.css + * filesize: 7638 Bytes + * last modified: Thu, 11 Dec 2014 17:26:11 +0100 + * + */ +#statementer { + min-height: 20px; + margin-top: 50px; +} + +#statementer .right { + float: right !important; +} + +#statementer #statementer_summary { + overflow: hidden; +} + +#statementer #statementer_summary ul { +} + +#statementer #statementer_summary ul li { + color: #FFF; + background-repeat: repeat-x; + background-position: top; + background-color: #333; + border-radius: 5px; + height: 160px; + text-align: center; + float: left; + list-style: none; + margin-left: 1.33%; + margin-bottom: 2%; + line-height: 40px; + padding-top: 10px; + overflow: hidden; + width: 18.65%; +} + +#statementer #statementer_summary ul li .statementer_currency { + font-size: 9px; + margin-right: -4px; +} + +#statementer #statementer_summary ul li:first-child { + margin-left: 0; +} + +#statementer h2 span.sortby { + font-size: 12px; +} + +#statementer h2 span a { + cursor: pointer; +} + +#statementer h2 span.sortorder { + float: right; + font-size: 15px; + padding-top: 4px; +} + +#statementer h2 span a.active { + color: #383838; +} + +#statementer #statementer_summary ul li h4 { + color: #FFF; + display: block; + white-space: nowrap; + height: 20px; + font-size: 30px; + line-height: 17px; + padding: 0; + font-weight: bold; +} + +#accordion .tab { + border-bottom-left-radius: 4px; + border-bottom-right-radius: 4px; +} + +.accordion-label { + border-radius: 4px; +} + +.accordion-label, img, #statementer #statementer_summary ul li { + -moz-transition-property: all; + -webkit-transition-property: all; + -o-transition-property: all; + transition-property: all; + -moz-transition-duration: 0.2s; + -webkit-transition-duration: 0.2s; + -o-transition-duration: 0.2s; + transition-duration: 0.2s; +} + +#statementer .accordion-label { + background: #F5F5F5; + color: #444; + cursor: pointer; + display: block; + line-height: 13px; + margin-bottom: 1px; + padding: 13px 13px 14px 13px; + position: relative; + outline: 0; +} + +#statementer .accordion-label .marketplace-icon { + display: inline; + padding: 13px 15px; + margin-right: 4px; +} + +#statementer .accordion-label.ui-state-active { + margin-bottom: 0px; + border-top-left-radius: 4px; + border-top-right-radius: 4px; + border-bottom-left-radius: 0px; + border-bottom-right-radius: 0px; +} + +#statementer .accordion-label:hover { + color: white; + background: #444; +} + +#statementer .accordion-label a { + color: #383838; +} + +#statementer .accordion-label.ui-state-active { + font-weight: 700; + color: white; + background: #444; +} + +#statementer .accordion-label.ui-state-active a { + color: #383838 !important; +} + +#statementer div.tabs ul li.ui-state-active a { + color: #444; + font-weight: 700; + background: #f5f5f5; + border-top-left-radius: 4px; + border-top-right-radius: 4px; +} + +#statementer div.tabs ul li a { + color: white; +} + +#statementer div.tabs { + max-height: 416px !important; + width: 984px !important; + background: #bbb; + padding: 10px 8px 16px; + border-bottom-left-radius: 4px; + border-bottom-right-radius: 4px; +} + +#statementer div.tab { + clear: both; + width: 952px !important; + height: 348px !important; + display: block; + padding: 18px 8px 0 8px !important; + overflow: hidden; + margin-bottom: 1px; + background: url(../img/loading.gif) no-repeat center #f5f5f5 !important; +} + +#content #statementer_copyright { + font-size: 10px !important; + text-align: right; + width: 100%; +} + +.percentage { + float: right; + line-height: 30px; +} + +.percentage input { + padding: 0 3px; + width: 32px; + text-align: right; + float: left; + border: 0; + background: 0; + line-height: 1em; + color: #444; + border-radius: 0; +} + +.percentage input:focus { + background: #eee; + font-weight: 700; +} + +#statementer_daterange { + text-align: center; + width: 100%; + margin: 0 0 10px; +} + +#statementer_date_from { +} + +#statementer_fetch_area { + width: 100%; + height: 400px; + font-family: "Courier New", Courier, monospace; + font-size: 10px; + resize: none; +} + +#statementer_dateslider { + margin: 0 10px 20px; + background: #D4D4D4; + border-radius: 4px; +} + +#statementer_dateslider a { + border-radius: 4px; + cursor: pointer !important; +} + +.statementer_menu { + /*float: right;*/ +} + +.statementer_menu a { + cursor: pointer; +} + +#statementer a.statementer_itemlink { + font-weight: 900 !important; + color: #444; +} + +#statementer a.statementer_itemlink:hover { + text-decoration: none; + color: #000; +} + +#statementer .ui-state-active a.statementer_itemlink { + color: #fff; +} + +#statementer .ui-state-active a.statementer_itemlink:hover { + text-decoration: none; + color: #ddd; +} + +#statementer .table-general { + margin-top: 10px; +} + +.table-general td { + white-space: nowrap; +} + +#statementer .ui-tabs { + position: relative; + padding: 0; + zoom: 1; +} + +#statementer .ui-tabs .ui-tabs-nav { + margin: 0; + padding: 0; +} + +#statementer .ui-tabs .ui-tabs-nav li { + list-style: none; + float: left; + position: relative; + top: 1px; + margin: 0 2px 1px 0; + border-bottom: 0 !important; + padding: 0; + white-space: nowrap; +} + +#statementer .ui-tabs .ui-tabs-nav li a { + float: left; + padding: .5em 1em; + text-decoration: none; +} + +#statementer .ui-tabs .ui-tabs-nav li.ui-tabs-selected { + margin-bottom: 0; + padding-bottom: 2px; +} + +#statementer .ui-tabs .ui-tabs-nav li.ui-tabs-selected a, .ui-tabs .ui-tabs-nav li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-state-processing a { + cursor: text; +} + +#statementer .ui-tabs .ui-tabs-nav li a, .ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a { + cursor: pointer; +} + +#statementer .ui-tabs .ui-tabs-panel { + display: block; + border-width: 0; + padding: 1em 1.4em; + background: none; +} + +#statementer .ui-tabs .ui-tabs-hide { + display: none !important; +} + +#statementer #statementer_dateslider.ui-slider { + position: relative; + text-align: left; +} + +#statementer #statementer_dateslider.ui-slider .ui-slider-handle { + position: absolute; + z-index: 2; + width: 1.4em; + height: 1.4em; + cursor: default; +} + +#statementer #statementer_dateslider.ui-slider .ui-slider-range { + position: absolute; + z-index: 1; + font-size: .7em; + display: block; + border: 0; + background-position: 0 0; +} + +#statementer #statementer_dateslider.ui-slider-horizontal { + height: .8em; +} + +#statementer #statementer_dateslider.ui-slider-horizontal .ui-slider-handle { + top: -.3em; + margin-left: -.6em; +} + +#statementer #statementer_dateslider.ui-slider-horizontal .ui-slider-range { + top: 0; + height: 100%; + background-color: #F5F5F5 !important; +} + +#statementer #statementer_dateslider.ui-slider-horizontal .ui-slider-range-min { + left: 0; +} + +#statementer #statementer_dateslider.ui-slider-horizontal .ui-slider-range-max { + right: 0; +} + +#statementer #statementer_dateslider.ui-slider-vertical { + width: .8em; + height: 100px; +} + +#statementer #statementer_dateslider.ui-slider-vertical .ui-slider-handle { + left: -.3em; + margin-left: 0; + margin-bottom: -.6em; +} + +#statementer #statementer_dateslider.ui-slider-vertical .ui-slider-range { + left: 0; + width: 100%; +} + +#statementer #statementer_dateslider.ui-slider-vertical .ui-slider-range-min { + bottom: 0; +} + +#statementer #statementer_dateslider.ui-slider-vertical .ui-slider-range-max { + top: 0; +} + +#sales_world_map_holder{ + display: none; +} +#sales_world_map{ + height:400px; +} \ No newline at end of file diff --git a/dashboard-plus-chrome-plugin/icon.png b/dashboard-plus-chrome-plugin/icon.png new file mode 100644 index 0000000..60c0fa2 Binary files /dev/null and b/dashboard-plus-chrome-plugin/icon.png differ diff --git a/dashboard-plus-chrome-plugin/img/replypantry-can.png b/dashboard-plus-chrome-plugin/img/replypantry-can.png new file mode 100644 index 0000000..e4792cc Binary files /dev/null and b/dashboard-plus-chrome-plugin/img/replypantry-can.png differ diff --git a/dashboard-plus-chrome-plugin/img/replypantry-edit.png b/dashboard-plus-chrome-plugin/img/replypantry-edit.png new file mode 100644 index 0000000..8f16d54 Binary files /dev/null and b/dashboard-plus-chrome-plugin/img/replypantry-edit.png differ diff --git a/dashboard-plus-chrome-plugin/index.html b/dashboard-plus-chrome-plugin/index.html new file mode 100644 index 0000000..a0a6364 --- /dev/null +++ b/dashboard-plus-chrome-plugin/index.html @@ -0,0 +1 @@ +Using Github pages to serve this JS nice and fast diff --git a/dashboard-plus-chrome-plugin/inject.js b/dashboard-plus-chrome-plugin/inject.js new file mode 100644 index 0000000..61e374f --- /dev/null +++ b/dashboard-plus-chrome-plugin/inject.js @@ -0,0 +1,2 @@ +window.dashboardplus = window.dashboardplus || {}; +window.dashboardplus['base'] = 'https://cdn.jsdelivr.net/gh/vrushank/dashboard-plus/'; \ No newline at end of file diff --git a/dashboard-plus-chrome-plugin/manifest.json b/dashboard-plus-chrome-plugin/manifest.json new file mode 100644 index 0000000..f91ae58 --- /dev/null +++ b/dashboard-plus-chrome-plugin/manifest.json @@ -0,0 +1,52 @@ +{ + "manifest_version": 3, + "name": "Dashboard Plus for Envato", + "version": "1.4.9", + "description": "Dashboard Plus for the Envato Market created by @revaxarts.", + "content_scripts": [ + { + "js": ["script.js"], + "matches": [ + "http://activeden.net/*", + "http://audiojungle.net/*", + "http://themeforest.net/*", + "http://videohive.net/*", + "http://graphicriver.net/*", + "http://3docean.net/*", + "http://codecanyon.net/*", + "http://photodune.net/*", + "https://activeden.net/*", + "https://audiojungle.net/*", + "https://themeforest.net/*", + "https://videohive.net/*", + "https://graphicriver.net/*", + "https://3docean.net/*", + "https://codecanyon.net/*", + "https://photodune.net/*" + ], + "run_at": "document_idle" + } + ], + "web_accessible_resources": [ + { + "resources": [ + "*.js", + "plugins/*.js", + "plugins/*.html", + "img/*.png", + "img/*.gif", + "css/*.css" + ], + "matches": [ + "" + ] + } + ], + "icons": { + "16": "icon.png", + "48": "icon.png", + "64": "icon.png", + "128": "icon.png" + } + } + \ No newline at end of file diff --git a/dashboard-plus-chrome-plugin/plugins/chaching.js b/dashboard-plus-chrome-plugin/plugins/chaching.js new file mode 100644 index 0000000..30f869f --- /dev/null +++ b/dashboard-plus-chrome-plugin/plugins/chaching.js @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2014 + * ================================== + * powered by revaxarts.com (http://revaxarts.com) + * original filename: chaching.js + * filesize: 2095 Bytes + * last modified: Thu, 12 Jun 2014 09:09:28 +0200 + * + */ +(function () { + + //"use strict" + + var username = $('#user_username').html(); + if (!username) return false; + + var interval = 5, + now = new Date().getTime(), + lastcheck = window.dashboardplus.getCookie('cha-ching_lastcheck'), + lastsales = window.dashboardplus.getCookie('cha-ching_lastsales'), + mp3 = 'https://dl.dropbox.com/u/9916342/cha-ching/cha-ching.mp3', + ogg = 'https://dl.dropbox.com/u/9916342/cha-ching/cha-ching.ogg', + $userbalance = $('.header-logo-account__balance'); + + setTimeout(start, Math.max(0, interval * 60000 - (now - lastcheck))); + + + function chachingIT() { + if(!window.dashboardplus.get('chaching', 'playsound')) return false; + if ($('#dbp-cha-ching').length) $('#cha-ching').remove(); + $('').appendTo('body'); + } + + function start() { + checkForSales(); + setInterval(function () { + checkForSales(); + }, interval * 60000); + } + + function checkForSales() { + $.get('/user/' + username, function (data) { + + //get current sales + var sales = data.match(/([^<]+)<\/strong>/); + //if we have last sales and lastcheck is set or the balance isn't equal the current balance + if (lastsales && !lastcheck || $userbalance.html() != balance[1]) { + $userbalance.html('New Sale! ' + balance[1]); + chachingIT(); + } + //our new lastsales + lastsales = sales[1]; + //} + + + //lastcheck was now + lastcheck = new Date().getTime(); + //save lastcheck but remove it if browser is closed (force check on restart) + window.dashboardplus.setCookie('cha-ching_lastcheck', lastcheck); + }); + } + +})(); diff --git a/dashboard-plus-chrome-plugin/plugins/compare_earnings.js b/dashboard-plus-chrome-plugin/plugins/compare_earnings.js new file mode 100644 index 0000000..d581ef8 --- /dev/null +++ b/dashboard-plus-chrome-plugin/plugins/compare_earnings.js @@ -0,0 +1,119 @@ +(function () { + + + var options = Chart.instances['chart-0'].options; + + var path,type,year,month,day,dropdown, + chart = Chart.instances['chart-0'], + nativedata, + externalAjax = true; + + $( document ).ajaxSuccess(function(response) { + if(externalAjax) init(); + }); + + $( window ).on('hashchange', function() { + update(); + }); + + init(); + update(); + + function init(){ + + path = location.pathname.replace(/\/user\/(.*)\/earnings\//, '').split('/'); + type = path[0]; + year = path[1] ? parseInt(path[1], 10) : null; + month = path[2] ? parseInt(path[2], 10) : null; + day = path[3] ? parseInt(path[3], 10) : null; + nativedata = $.parseJSON($('#graphdata').html()); + + if(dropdown) dropdown.remove(); + dropdown = ''; + dropdown = $(dropdown); + + $('.earning__breadcrumb').append(dropdown); + + dropdown.on('change', function(){ + location.hash = '/'+$(this).val(); + }); + + + } + + function update(){ + var _path = location.hash.substring(1).split('/'); + var _year = _path[1] && year ? parseInt(_path[1], 10) : null; + var _month = _path[2] && month ? parseInt(_path[2], 10) : null; + var _day = _path[3] && day ? parseInt(_path[3], 10) : null; + + if(!_year) return; + + externalAjax = false; + get_data(_year, _month, _day, function(data){ + externalAjax = true; + data.datasets[0].fillColor = "rgba(151,187,205,0.2)"; + data.datasets[0].strokeColor = "rgba(151,187,205,0.4)"; + data.datasets[0].pointColor = "rgba(151,187,205,0.4)"; + data.datasets[0].pointStrokeColor = "#fff"; + data.datasets[0].pointHighlightFill = "#fff"; + data.datasets[0].pointHighlightStroke = "rgba(151,187,205,0.5)"; + + nativedata.datasets[1] = data.datasets[0]; + chart.datasets = nativedata.datasets; + chart.chart.Line(nativedata, options); + //chart.update(); + + }); + } + + function get_data(year, month, day, callback){ + var time = (year ? '/'+year+(month ? '/'+month+(day ? '/'+day : '') : '') : ''); + var url = location.pathname.replace(/\/earnings\/(.*)$/, '')+'/earnings/'+type+time+'?_pjax=.js-pjax-container'; + $.ajax({ + url: url, + headers: { 'X-PJAX': true, 'X-PJAX-Container': '.js-pjax-container' }, + success: function(response){ + var data = $.parseJSON($('
    ').html(response).find('#graphdata').html()); + callback && callback(data); + } + + }); + } + + + +})(); diff --git a/dashboard-plus-chrome-plugin/plugins/editinline.js b/dashboard-plus-chrome-plugin/plugins/editinline.js new file mode 100644 index 0000000..d8276be --- /dev/null +++ b/dashboard-plus-chrome-plugin/plugins/editinline.js @@ -0,0 +1,3109 @@ +/* + * Copyright (c) 2014 + * ================================== + * powered by revaxarts.com (http://revaxarts.com) + * original filename: editinline.js + * filesize: 81841 Bytes + * last modified: Thu, 23 May 2013 10:33:00 +0200 + * + */ +(function () { + + var pagetabs = $('#page-tabs').find('li'), + itemlink = pagetabs.first().find('a').attr('href'); + + if(pagetabs.length < 4) return false; + + addCSS(window.dashboardplus['base']+'/css/jquery.wysiwyg.css', '', function(){ + + if (location.href.match(/^http:\/\/([\.a-z3]+)\.(net|com)\/item\/([a-z0-9-]+)\/(edit)\/([a-z0-9-]+)/)) { + $('h2').first().append(' or edit inline'); + } + + if (location.href.match(/^http:\/\/([\.a-z3]+)\.(net|com)\/item\/([a-z0-9-]+)\/([a-z0-9-]+)/)) { + if (location.hash == '#edit_inline') { + init(); + } + + itemlink = location.href; + } + + $('
  • Edit Inline
  • ').insertBefore(pagetabs.last()); + + + $('#edit_inline_btn').click(init); + + function init(){ + + var content = $('.item-description'), + contentpos = content.position(), + textarea = $('').insertAfter(textarea); + + textarea.wysiwyg({ + 'css': envatostyle, + 'autoGrow': true, + 'html': 'INITIAL_CONTENT', + }); + content.hide(); + + var toolbar = $('.toolbar'), + toolbarfixed = false; + + + overlay.show().fadeTo(200,0.5); + + $(window).on('scroll', function(){ + if(window.scrollY+20 > contentpos.top){ + if(!toolbarfixed){ + toolbar.addClass('fixed'); + infobox.addClass('fixed').css({ + 'top': 70 + }); + toolbarfixed = true; + } + }else{ + if(toolbarfixed){ + toolbar.removeClass('fixed'); + infobox.removeClass('fixed').css({ + 'top': contentpos.top+70 + }); + toolbarfixed = false; + } + } + //console.log(window); + }).trigger('scroll'); + + infobox.removeClass('fixed').css({ + 'top': contentpos.top+70, + 'left': contentpos.left+650 + }); + + + $('#inline-description-save').click(function(){ + + var html = textarea.val(), + posturl = pagetabs.eq(3).find('a').attr('href'); + + html = html + .replace(/<\/?tbody>/g,'') + .replace(//g,'') + .replace(/<\/b>/g,'') + .replace(//g,'') + .replace(/<\/i>/g,'') + .replace(//g,'') + .replace(/<\/strike>/g,'') + ; + $('#item_description_form').find('textarea').val($.trim(html)); + $('#item_description_form').submit(); + + + }); + $('#inline-description-cancel').click(function(){ + + textarea.wysiwyg("destroy"); + content.show(); + overlay.remove(); + infobox.remove(); + textarea.remove(); + $('#edit_inline_btn').parent().removeClass('selected'); + $('#item_description_form').remove(); + return false; + + }); + } + + return false; + + }); + + + + + + function addCSS(url, ID, callback){ + var d = document; + var head = d.getElementsByTagName('head')[0]; + var link = d.createElement('link'); + if(ID) link.id = ID; + link.rel = 'stylesheet'; + link.type = 'text/css'; + link.href = url+'?c='+new Date().getTime();; + link.media = 'all'; + link.onload = function(){ + callback && callback(); + }; + head.appendChild(link); + } + +})(); + +/** + * WYSIWYG - jQuery plugin 0.97 + * (0.97.2 - From infinity) + * + * Copyright (c) 2008-2009 Juan M Martinez, 2010-2011 Akzhan Abdulin and all contributors + * https://github.com/akzhan/jwysiwyg + * + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + * + */ + +/*jslint browser: true, forin: true */ + +(function ($) { + "use strict"; + /* Wysiwyg namespace: private properties and methods */ + + var console = window.console ? window.console : { + log: $.noop, + error: function (msg) { + $.error(msg); + } + }; + + var is_opera = /opera/i.test(window.navigator.userAgent); + var is_webkit = /webkit/i.test(window.navigator.userAgent); + var is_firefox = /firefox/i.test(window.navigator.userAgent); + var is_msie = /msie/i.test(window.navigator.userAgent); + var is_mozilla = /mozilla/i.test(window.navigator.userAgent); + + + var supportsProp = (('prop' in $.fn) && ('removeProp' in $.fn)); + + function Wysiwyg() { + // - the item is added by this.ui.appendControls and then appendItem + // - click triggers this.triggerControl + // cmd or[key] - designMode exec function name + // tags - activates control for these tags (@see checkTargets) + // css - activates control if one of css is applied + this.controls = { + + copy: { + groupIndex: 8, + visible: false, + tooltip: "Copy" + }, + + createLink: { + groupIndex: 6, + visible: true, + exec: function () { + var self = this; + if ($.wysiwyg.controls && $.wysiwyg.controls.link) { + $.wysiwyg.controls.link.init(this); + } else if ($.wysiwyg.autoload) { + $.wysiwyg.autoload.control("wysiwyg.link.js", function () { + self.controls.createLink.exec.apply(self); + }); + } else { + console.error("$.wysiwyg.controls.link not defined. You need to include wysiwyg.link.js file"); + } + }, + tags: ["a"], + tooltip: "Create link" + }, + + unLink : { + groupIndex: 6, + visible: true, + exec : function() { + this.editorDoc.execCommand("unlink", false, null); + }, + tooltip: "Remove link" + }, + + cut: { + groupIndex: 8, + visible: false, + tooltip: "Cut" + }, + + decreaseFontSize: { + groupIndex: 9, + visible: false, + tags: ["small"], + tooltip: "Decrease font size", + exec: function () { + this.decreaseFontSize(); + } + }, + + h1: { + groupIndex: 0, + visible: false, + className: "h1", + command: (is_msie || is_webkit) ? "FormatBlock" : "heading", + "arguments": (is_msie || is_webkit) ? "

    " : "h1", + tags: ["h1"], + tooltip: "Header 1" + }, + + h2: { + groupIndex: 0, + visible: true, + className: "h2", + command: (is_msie || is_webkit) ? "FormatBlock" : "heading", + "arguments": (is_msie || is_webkit) ? "

    " : "h2", + tags: ["h2"], + tooltip: "Header 2" + }, + + h3: { + groupIndex: 0, + visible: true, + className: "h3", + command: (is_msie || is_webkit) ? "FormatBlock" : "heading", + "arguments": (is_msie || is_webkit) ? "

    " : "h3", + tags: ["h3"], + tooltip: "Header 3" + }, + + h4: { + groupIndex: 0, + visible: true, + className: "h4", + command: (is_msie || is_webkit) ? "FormatBlock" : "heading", + "arguments": (is_msie || is_webkit) ? "

    " : "h4", + tags: ["h4"], + tooltip: "Header 4" + }, + + h5: { + groupIndex: 0, + visible: true, + className: "h5", + command: (is_msie || is_webkit) ? "FormatBlock" : "heading", + "arguments": (is_msie || is_webkit) ? "

    " : "h5", + tags: ["h5"], + tooltip: "Header 5" + }, + + h6: { + groupIndex: 0, + visible: true, + className: "h6", + command: (is_msie || is_webkit) ? "FormatBlock" : "heading", + "arguments": (is_msie || is_webkit) ? "
    " : "h6", + tags: ["h6"], + tooltip: "Header 6" + }, + + highlight: { + tooltip: "Highlight", + className: "highlight", + groupIndex: 1, + visible: false, + css: { + backgroundColor: "rgb(255, 255, 102)" + }, + exec: function () { + var command, node, selection, args; + + if (is_msie || is_webkit) { + command = "backcolor"; + } else { + command = "hilitecolor"; + } + + if (is_msie) { + node = this.getInternalRange().parentElement(); + } else { + selection = this.getInternalSelection(); + node = selection.extentNode || selection.focusNode; + + while (node.style === undefined) { + node = node.parentNode; + if (node.tagName && node.tagName.toLowerCase() === "body") { + return; + } + } + } + + if (node.style.backgroundColor === "rgb(255, 255, 102)" || + node.style.backgroundColor === "#ffff66") { + args = "#ffffff"; + } else { + args = "#ffff66"; + } + + this.editorDoc.execCommand(command, false, args); + } + }, + + html: { + groupIndex: 10, + visible: true, + exec: function () { + var elementHeight; + + if (this.options.resizeOptions && $.fn.resizable) { + elementHeight = this.element.height(); + } + + if (this.viewHTML) { //textarea is shown + this.setContent(this.original.value); + + $(this.original).hide(); + this.editor.show(); + + if (this.options.resizeOptions && $.fn.resizable) { + // if element.height still the same after frame was shown + if (elementHeight === this.element.height()) { + this.element.height(elementHeight + this.editor.height()); + } + + this.element.resizable($.extend(true, { + alsoResize: this.editor + }, this.options.resizeOptions)); + } + + this.ui.toolbar.find("li").each(function () { + var li = $(this); + + if (li.hasClass("html")) { + li.removeClass("active"); + } else { + li.removeClass('disabled'); + } + }); + } else { //wysiwyg is shown + this.saveContent(); + + $(this.original).css({ + width: this.element.outerWidth() - 6, + height: this.element.height() - this.ui.toolbar.height() - 6, + resize: "none" + }).show(); + this.editor.hide(); + + if (this.options.resizeOptions && $.fn.resizable) { + // if element.height still the same after frame was hidden + if (elementHeight === this.element.height()) { + this.element.height(this.ui.toolbar.height()); + } + + this.element.resizable("destroy"); + } + + this.ui.toolbar.find("li").each(function () { + var li = $(this); + + if (li.hasClass("html")) { + li.addClass("active"); + } else { + if (false === li.hasClass("fullscreen")) { + li.removeClass("active").addClass('disabled'); + } + } + }); + } + + this.viewHTML = !(this.viewHTML); + }, + tooltip: "View source code" + }, + + increaseFontSize: { + groupIndex: 9, + visible: false, + tags: ["big"], + tooltip: "Increase font size", + exec: function () { + this.increaseFontSize(); + } + }, + + indent: { + groupIndex: 2, + visible: false, + tooltip: "Indent" + }, + + insertHorizontalRule: { + groupIndex: 6, + visible: true, + tags: ["hr"], + tooltip: "Insert Horizontal Rule" + }, + + insertImage: { + groupIndex: 6, + visible: true, + exec: function () { + var url; + var self = this; + if(url = prompt('Insert a valid image URL', '')){ + var image = ""; + self.insertHtml(image); + } + + }, + tags: ["img"], + tooltip: "Insert image" + }, + + insertOrderedList: { + groupIndex: 5, + visible: true, + tags: ["ol"], + tooltip: "Insert Ordered List" + }, + + insertTable: { + groupIndex: 6, + visible: true, + exec: function () { + var self = this; + + if ($.wysiwyg.controls && $.wysiwyg.controls.table) { + $.wysiwyg.controls.table(this); + } else if ($.wysiwyg.autoload) { + $.wysiwyg.autoload.control("wysiwyg.table.js", function () { + self.controls.insertTable.exec.apply(self); + }); + } else { + console.error("$.wysiwyg.controls.table not defined. You need to include wysiwyg.table.js file"); + } + }, + tags: ["table"], + tooltip: "Insert table" + }, + + insertUnorderedList: { + groupIndex: 5, + visible: true, + tags: ["ul"], + tooltip: "Insert Unordered List" + }, + + bold: { + groupIndex: 0, + visible: true, + tags: ["strong", "b"], + css: { + fontWeight: "bold" + }, + tooltip: "Bold", + hotkey: {"ctrl": 1, "key": 66} + }, + italic: { + groupIndex: 0, + visible: true, + tags: ["i", "em"], + css: { + fontStyle: "italic" + }, + tooltip: "Italic", + hotkey: {"ctrl": 1, "key": 73} + }, + + justifyCenter: { + groupIndex: 1, + visible: false, + tags: ["center"], + css: { + textAlign: "center" + }, + tooltip: "Justify Center" + }, + + justifyFull: { + groupIndex: 1, + visible: false, + css: { + textAlign: "justify" + }, + tooltip: "Justify Full" + }, + + justifyLeft: { + visible: false, + groupIndex: 1, + css: { + textAlign: "left" + }, + tooltip: "Justify Left" + }, + + justifyRight: { + groupIndex: 1, + visible: false, + css: { + textAlign: "right" + }, + tooltip: "Justify Right" + }, + + ltr: { + groupIndex: 10, + visible: false, + exec: function () { + var p = this.dom.getElement("p"); + + if (!p) { + return false; + } + + $(p).attr("dir", "ltr"); + return true; + }, + tooltip : "Left to Right" + }, + + outdent: { + groupIndex: 2, + visible: false, + tooltip: "Outdent" + }, + + paragraph: { + groupIndex: 0, + visible: true, + className: "paragraph", + command: "FormatBlock", + "arguments": (is_msie || is_webkit) ? "

    " : "p", + tags: ["p"], + tooltip: "Paragraph" + }, + + paste: { + groupIndex: 8, + visible: false, + tooltip: "Paste" + }, + + undo: { + groupIndex: 4, + visible: true, + tooltip: "Undo" + }, + + redo: { + groupIndex: 4, + visible: true, + tooltip: "Redo" + }, + + removeFormat: { + groupIndex: 10, + visible: true, + exec: function () { + this.removeFormat(); + }, + tooltip: "Remove formatting" + }, + + rtl: { + groupIndex: 10, + visible: false, + exec: function () { + var p = this.dom.getElement("p"); + + if (!p) { + return false; + } + + $(p).attr("dir", "rtl"); + return true; + }, + tooltip : "Right to Left" + }, + + strikeThrough: { + groupIndex: 0, + visible: true, + tags: ["s", "strike"], + css: { + textDecoration: "line-through" + }, + tooltip: "Strike-through" + }, + + subscript: { + groupIndex: 3, + visible: false, + tags: ["sub"], + tooltip: "Subscript" + }, + + superscript: { + groupIndex: 3, + visible: false, + tags: ["sup"], + tooltip: "Superscript" + }, + + underline: { + groupIndex: 0, + visible: true, + tags: ["u"], + css: { + textDecoration: "underline" + }, + tooltip: "Underline", + hotkey: {"ctrl": 1, "key": 85} + }, + + pre: { + visible : true, + groupIndex: 6, + tooltip: "Code Block", + command: "FormatBlock", + "arguments": (is_msie || is_webkit) ? "

    " : "pre",
    +				tags: ["pre"],
    +			},
    +			
    +			code: {
    +				visible : true,
    +				groupIndex: 6,
    +				tooltip: "Code snippet",
    +				exec: function () {
    +					var range	= this.getInternalRange(),
    +						common	= $(range.commonAncestorContainer),
    +						$nodeName = range.commonAncestorContainer.nodeName.toLowerCase();
    +					if (common.parent("code").length) {
    +						common.unwrap();
    +					} else {
    +						if ($nodeName !== "body") {
    +							common.wrap("");
    +						}
    +					}
    +				}
    +			},
    +			
    +			cssWrap: {
    +				visible : false,
    +				groupIndex: 6,
    +				tooltip: "CSS Wrapper",
    +				exec: function () { 
    +					$.wysiwyg.controls.cssWrap.init(this);
    +				}
    +			}
    +			
    +		};
    +
    +		this.defaults = {
    +html: 'INITIAL_CONTENT',
    +			debug: false,
    +			controls: {},
    +			css: {},
    +			events: {},
    +			autoGrow: false,
    +			autoSave: true,
    +			brIE: true,					// http://code.google.com/p/jwysiwyg/issues/detail?id=15
    +			formHeight: 270,
    +			formWidth: 440,
    +			iFrameClass: null,
    +			initialContent: "

    Initial content

    ", + maxHeight: 10000, // see autoGrow + maxLength: 0, + messages: { + nonSelection: "Select the text you wish to link" + }, + toolbarHtml: '', + removeHeadings: false, + replaceDivWithP: false, + resizeOptions: false, + rmUnusedControls: false, // https://github.com/akzhan/jwysiwyg/issues/52 + rmUnwantedBr: true, // http://code.google.com/p/jwysiwyg/issues/detail?id=11 + tableFiller: "Lorem ipsum", + initialMinHeight: null, + + controlImage: { + forceRelativeUrls: false + }, + + controlLink: { + forceRelativeUrls: false + }, + + plugins: { // placeholder for plugins settings + autoload: false, + i18n: false, + rmFormat: { + rmMsWordMarkup: false + } + }, + + dialog : "default" + }; + + //these properties are set from control hashes + this.availableControlProperties = [ + "arguments", + "callback", + "className", + "command", + "css", + "custom", + "exec", + "groupIndex", + "hotkey", + "icon", + "tags", + "tooltip", + "visible" + ]; + + this.editor = null; //jquery iframe holder + this.editorDoc = null; + this.element = null; + this.options = {}; + this.original = null; + this.savedRange = null; + this.timers = []; + this.validKeyCodes = [8, 9, 13, 16, 17, 18, 19, 20, 27, 33, 34, 35, 36, 37, 38, 39, 40, 45, 46]; + + this.isDestroyed = false; + + this.dom = { // DOM related properties and methods + ie: { + parent: null // link to dom + }, + w3c: { + parent: null // link to dom + } + }; + this.dom.parent = this; + this.dom.ie.parent = this.dom; + this.dom.w3c.parent = this.dom; + + this.ui = {}; // UI related properties and methods + this.ui.self = this; + this.ui.toolbar = null; + this.ui.initialHeight = null; // ui.grow + + this.dom.getAncestor = function (element, filterTagName) { + filterTagName = filterTagName.toLowerCase(); + + while (element && typeof element.tagName != "undefined" && "body" !== element.tagName.toLowerCase()) { + if (filterTagName === element.tagName.toLowerCase()) { + return element; + } + + element = element.parentNode; + } + if(!element.tagName && (element.previousSibling || element.nextSibling)) { + if(element.previousSibling) { + if(element.previousSibling.tagName.toLowerCase() == filterTagName) { + return element.previousSibling; + } + } + if(element.nextSibling) { + if(element.nextSibling.tagName.toLowerCase() == filterTagName) { + return element.nextSibling; + } + } + } + + return null; + }; + + this.dom.getElement = function (filterTagName) { + var dom = this; + + filterTagName = filterTagName.toLowerCase(); + + if (window.getSelection) { + return dom.w3c.getElement(filterTagName); + } else { + return dom.ie.getElement(filterTagName); + } + }; + + this.dom.ie.getElement = function (filterTagName) { + var dom = this.parent, + selection = dom.parent.getInternalSelection(), + range = selection.createRange(), + element; + + if ("Control" === selection.type) { + // control selection + if (1 === range.length) { + element = range.item(0); + } else { + // multiple control selection + return null; + } + } else { + element = range.parentElement(); + } + + return dom.getAncestor(element, filterTagName); + }; + + this.dom.w3c.getElement = function (filterTagName) { + var dom = this.parent, + range = dom.parent.getInternalRange(), + element; + + if (!range) { + return null; + } + + element = range.commonAncestorContainer; + + if (3 === element.nodeType) { + element = element.parentNode; + } + + // if startContainer not Text, Comment, or CDATASection element then + // startOffset is the number of child nodes between the start of the + // startContainer and the boundary point of the Range + if (element === range.startContainer) { + element = element.childNodes[range.startOffset]; + } + + if(!element.tagName && (element.previousSibling || element.nextSibling)) { + if(element.previousSibling) { + if(element.previousSibling.tagName.toLowerCase() == filterTagName) { + return element.previousSibling; + } + } + if(element.nextSibling) { + if(element.nextSibling.tagName.toLowerCase() == filterTagName) { + return element.nextSibling; + } + } + } + + return dom.getAncestor(element, filterTagName); + }; + + this.ui.addHoverClass = function () { + $(this).addClass("wysiwyg-button-hover"); + }; + + this.ui.appendControls = function () { + var ui = this, + self = this.self, + controls = self.parseControls(), + hasVisibleControls = true, // to prevent separator before first item + groups = [], + controlsByGroup = {}, + i, + currentGroupIndex, // jslint wants all vars at top of function + iterateGroup = function (controlName, control) { //called for every group when adding + if (control.groupIndex && currentGroupIndex !== control.groupIndex) { + currentGroupIndex = control.groupIndex; + hasVisibleControls = false; + } + + if (!control.visible) { + return; + } + + if (!hasVisibleControls) { + ui.appendItemSeparator(); + hasVisibleControls = true; + } + + if (control.custom) { + ui.appendItemCustom(controlName, control); + } else { + ui.appendItem(controlName, control); + } + }; + + $.each(controls, function (name, c) { //sort by groupIndex + var index = "empty"; + + if (undefined !== c.groupIndex) { + if ("" === c.groupIndex) { + index = "empty"; + } else { + index = c.groupIndex; + } + } + + if (undefined === controlsByGroup[index]) { + groups.push(index); + controlsByGroup[index] = {}; + } + controlsByGroup[index][name] = c; + }); + + groups.sort(function (a, b) { //just sort group indexes by + if ("number" === typeof (a) && typeof (a) === typeof (b)) { + return (a - b); + } else { + a = a.toString(); + b = b.toString(); + + if (a > b) { + return 1; + } + + if (a === b) { + return 0; + } + + return -1; + } + }); + + if (0 < groups.length) { + // set to first index in groups to proper placement of separator + currentGroupIndex = groups[0]; + } + + for (i = 0; i < groups.length; i += 1) { + $.each(controlsByGroup[groups[i]], iterateGroup); + } + }; + + this.ui.appendItem = function (name, control) { + var self = this.self, + className = control.className || control.command || name || "empty", + tooltip = control.tooltip || control.command || name || ""; + + return $('
  • ' + (className) + "
  • ") + .addClass(className) + .attr("title", tooltip) + .hover(this.addHoverClass, this.removeHoverClass) + .click(function (event) { + if ($(this).hasClass("disabled")) { + return false; + } + + self.triggerControl.apply(self, [name, control]); + + /** + * @link https://github.com/akzhan/jwysiwyg/issues/219 + */ + var $target = $(event.target); + for (var controlName in self.controls) { + if ($target.hasClass(controlName)) { + self.ui.toolbar.find("." + controlName).toggleClass("active"); + self.editorDoc.rememberCommand = true; + break; + } + } + + this.blur(); + self.ui.returnRange(); + self.ui.focus(); + return true; + }) + .appendTo(self.ui.toolbar); + }; + + this.ui.appendItemCustom = function (name, control) { + var self = this.self, + tooltip = control.tooltip || control.command || name || ""; + + if (control.callback) { + $(window).bind("trigger-" + name + ".wysiwyg", control.callback); + } + + return $('
  • ') + .addClass("custom-command-" + name) + .addClass("wysiwyg-custom-command") + .addClass(name) + .attr("title", tooltip) + .hover(this.addHoverClass, this.removeHoverClass) + .click(function () { + if ($(this).hasClass("disabled")) { + return false; + } + + self.triggerControl.apply(self, [name, control]); + + this.blur(); + self.ui.returnRange(); + self.ui.focus(); + + self.triggerControlCallback(name); + return true; + }) + .appendTo(self.ui.toolbar); + }; + + this.ui.appendItemSeparator = function () { + var self = this.self; + return $('').appendTo(self.ui.toolbar); + }; + + this.autoSaveFunction = function () { + this.saveContent(); + }; + + //called after click in wysiwyg "textarea" + this.ui.checkTargets = function (element) { + var self = this.self; + + //activate controls + $.each(self.options.controls, function (name, control) { + var className = control.className || control.command || name || "empty", + tags, + elm, + css, + el, + checkActiveStatus = function (cssProperty, cssValue) { + var handler; + + if ("function" === typeof (cssValue)) { + handler = cssValue; + if (handler(el.css(cssProperty).toString().toLowerCase(), self)) { + self.ui.toolbar.find("." + className).addClass("active"); + } + } else { + if (el.css(cssProperty).toString().toLowerCase() === cssValue) { + self.ui.toolbar.find("." + className).addClass("active"); + } + } + }; + + if ("fullscreen" !== className) { + self.ui.toolbar.find("." + className).removeClass("active"); + } + + //activate by allowed tags + if (control.tags || (control.options && control.options.tags)) { + tags = control.tags || (control.options && control.options.tags); + + elm = element; + while (elm) { + if (elm.nodeType !== 1) { + break; + } + + if ($.inArray(elm.tagName.toLowerCase(), tags) !== -1) { + self.ui.toolbar.find("." + className).addClass("active"); + } + + elm = elm.parentNode; + } + } + + //activate by supposed css + if (control.css || (control.options && control.options.css)) { + css = control.css || (control.options && control.options.css); + el = $(element); + + while (el) { + if (el[0].nodeType !== 1) { + break; + } + $.each(css, checkActiveStatus); + + el = el.parent(); + } + } + }); + }; + + this.ui.designMode = function () { + var attempts = 3, + self = this.self, + runner; + runner = function (attempts) { + if ("on" === self.editorDoc.designMode) { + if (self.timers.designMode) { + window.clearTimeout(self.timers.designMode); + } + + // IE needs to reget the document element (this.editorDoc) after designMode was set + if (self.innerDocument() !== self.editorDoc) { + self.ui.initFrame(); + } + + return; + } + + try { + self.editorDoc.designMode = "on"; + } catch (e) { + } + + attempts -= 1; + if (attempts > 0) { + self.timers.designMode = window.setTimeout(function () { runner(attempts); }, 100); + } + }; + + runner(attempts); + }; + + this.destroy = function () { + this.isDestroyed = true; + + var i, $form = this.element.closest("form"); + + for (i = 0; i < this.timers.length; i += 1) { + window.clearTimeout(this.timers[i]); + } + + // Remove bindings + $form.unbind(".wysiwyg"); + this.element.remove(); + $.removeData(this.original, "wysiwyg"); + $(this.original).show(); + return this; + }; + + this.getRangeText = function () { + var r = this.getInternalRange(); + + if (r.toString) { + r = r.toString(); + } else if (r.text) { // IE + r = r.text; + } + + return r; + }; + //not used? + this.execute = function (command, arg) { + if (typeof (arg) === "undefined") { + arg = null; + } + this.editorDoc.execCommand(command, false, arg); + }; + + this.extendOptions = function (options) { + var controls = {}; + + /** + * If the user set custom controls, we catch it, and merge with the + * defaults controls later. + */ + if ("object" === typeof options.controls) { + controls = options.controls; + delete options.controls; + } + + options = $.extend(true, {}, this.defaults, options); + options.controls = $.extend(true, {}, controls, this.controls, controls); + + if (options.rmUnusedControls) { + $.each(options.controls, function (controlName) { + if (!controls[controlName]) { + delete options.controls[controlName]; + } + }); + } + + return options; + }; + + this.ui.focus = function () { + var self = this.self; + + self.editor.get(0).contentWindow.focus(); + return self; + }; + + this.ui.returnRange = function () { + var self = this.self, sel; + + if (self.savedRange !== null) { + if (window.getSelection) { //non IE and there is already a selection + sel = window.getSelection(); + if (sel.rangeCount > 0) { + sel.removeAllRanges(); + } + try { + sel.addRange(self.savedRange); + } catch (e) { + console.error(e); + } + } else if (window.document.createRange) { // non IE and no selection + window.getSelection().addRange(self.savedRange); + } else if (window.document.selection) { //IE + self.savedRange.select(); + } + + self.savedRange = null; + } + }; + + this.increaseFontSize = function () { + if (is_mozilla || is_opera) { + this.editorDoc.execCommand("increaseFontSize", false, null); + } else if (is_webkit) { + var Range = this.getInternalRange(), + Selection = this.getInternalSelection(), + newNode = this.editorDoc.createElement("big"); + + // If cursor placed on text node + if (true === Range.collapsed && 3 === Range.commonAncestorContainer.nodeType) { + var text = Range.commonAncestorContainer.nodeValue.toString(), + start = text.lastIndexOf(" ", Range.startOffset) + 1, + end = (-1 === text.indexOf(" ", Range.startOffset)) ? text : text.indexOf(" ", Range.startOffset); + + Range.setStart(Range.commonAncestorContainer, start); + Range.setEnd(Range.commonAncestorContainer, end); + + Range.surroundContents(newNode); + Selection.addRange(Range); + } else { + Range.surroundContents(newNode); + Selection.removeAllRanges(); + Selection.addRange(Range); + } + } else { + console.error("Internet Explorer?"); + } + }; + + this.decreaseFontSize = function () { + if (is_mozilla || is_opera) { + this.editorDoc.execCommand("decreaseFontSize", false, null); + } else if (is_webkit) { + var Range = this.getInternalRange(), + Selection = this.getInternalSelection(), + newNode = this.editorDoc.createElement("small"); + + // If cursor placed on text node + if (true === Range.collapsed && 3 === Range.commonAncestorContainer.nodeType) { + var text = Range.commonAncestorContainer.nodeValue.toString(), + start = text.lastIndexOf(" ", Range.startOffset) + 1, + end = (-1 === text.indexOf(" ", Range.startOffset)) ? text : text.indexOf(" ", Range.startOffset); + + Range.setStart(Range.commonAncestorContainer, start); + Range.setEnd(Range.commonAncestorContainer, end); + + Range.surroundContents(newNode); + Selection.addRange(Range); + } else { + Range.surroundContents(newNode); + Selection.removeAllRanges(); + Selection.addRange(Range); + } + } else { + console.error("Internet Explorer?"); + } + }; + + this.getContent = function () { + if (this.viewHTML) { + this.setContent(this.original.value); + } + return this.events.filter('getContent', this.editorDoc.body.innerHTML); + }; + + /** + * A jWysiwyg specific event system. + * + * Example: + * + * $("#editor").getWysiwyg().events.bind("getContent", function (orig) { + * return "
    "+orgi+"
    "; + * }); + * + * This makes it so that when ever getContent is called, it is wrapped in a div#content. + */ + this.events = { + _events : {}, + + /** + * Similar to jQuery's bind, but for jWysiwyg only. + */ + bind : function (eventName, callback) { + if (typeof (this._events.eventName) !== "object") { + this._events[eventName] = []; + } + this._events[eventName].push(callback); + }, + + /** + * Similar to jQuery's trigger, but for jWysiwyg only. + */ + trigger : function (eventName, args) { + if (typeof (this._events.eventName) === "object") { + var editor = this.editor; + $.each(this._events[eventName], function (k, v) { + if (typeof (v) === "function") { + v.apply(editor, args); + } + }); + } + }, + + /** + * This "filters" `originalText` by passing it as the first argument to every callback + * with the name `eventName` and taking the return value and passing it to the next function. + * + * This function returns the result after all the callbacks have been applied to `originalText`. + */ + filter : function (eventName, originalText) { + if (typeof (this._events[eventName]) === "object") { + var editor = this.editor, + args = Array.prototype.slice.call(arguments, 1); + + $.each(this._events[eventName], function (k, v) { + if (typeof (v) === "function") { + originalText = v.apply(editor, args); + } + }); + } + return originalText; + } + }; + + this.getElementByAttributeValue = function (tagName, attributeName, attributeValue) { + var i, value, elements = this.editorDoc.getElementsByTagName(tagName); + + for (i = 0; i < elements.length; i += 1) { + value = elements[i].getAttribute(attributeName); + + if (is_msie) { + /** IE add full path, so I check by the last chars. */ + value = value.substr(value.length - attributeValue.length); + } + + if (value === attributeValue) { + return elements[i]; + } + } + + return false; + }; + + this.getInternalRange = function () { + var selection = this.getInternalSelection(); + + if (!selection) { + return null; + } + + if (selection.rangeCount && selection.rangeCount > 0) { // w3c + return selection.getRangeAt(0); + } else if (selection.createRange) { // ie + return selection.createRange(); + } + + return null; + }; + + this.getInternalSelection = function () { + // firefox: document.getSelection is deprecated + if (this.editor.get(0).contentWindow) { + if (this.editor.get(0).contentWindow.getSelection) { + return this.editor.get(0).contentWindow.getSelection(); + } + if (this.editor.get(0).contentWindow.selection) { + return this.editor.get(0).contentWindow.selection; + } + } + if (this.editorDoc.getSelection) { + return this.editorDoc.getSelection(); + } + if (this.editorDoc.selection) { + return this.editorDoc.selection; + } + + return null; + }; + + this.getRange = function () { + var selection = this.getSelection(); + + if (!selection) { + return null; + } + + if (selection.rangeCount && selection.rangeCount > 0) { // w3c + selection.getRangeAt(0); + } else if (selection.createRange) { // ie + return selection.createRange(); + } + + return null; + }; + + this.getSelection = function () { + return (window.getSelection) ? window.getSelection() : window.document.selection; + }; + + // :TODO: you can type long string and letters will be hidden because of overflow + this.ui.grow = function () { + var self = this.self, + innerBody = $(self.editorDoc.body), + innerHeight = is_msie ? innerBody[0].scrollHeight : innerBody.height() + 2 + 20, // 2 - borders, 20 - to prevent content jumping on grow + minHeight = self.ui.initialHeight, + height = Math.max(innerHeight, minHeight); + + height = Math.min(height, self.options.maxHeight); + + self.editor.attr("scrolling", height < self.options.maxHeight ? "no" : "auto"); // hide scrollbar firefox + innerBody.css("overflow", height < self.options.maxHeight ? "hidden" : ""); // hide scrollbar chrome + + self.editor.get(0).height = height; + + return self; + }; + + this.init = function (element, options) { + var self = this, + $form = $(element).closest("form"), + newX = (element.width || element.clientWidth || 0), + newY = (element.height || element.clientHeight || 0) + ; + + this.options = this.extendOptions(options); + this.original = element; + this.ui.toolbar = $(this.options.toolbarHtml); + + if (is_msie && parseInt(is_version, 10) < 8) { + this.options.autoGrow = false; + } + + if (newX === 0 && element.cols) { + newX = (element.cols * 8) + 21; + } + if (newY === 0 && element.rows) { + newY = (element.rows * 16) + 16; + } + + this.editor = $(window.location.protocol === "https:" ? '' : "").attr("frameborder", "0"); + + if (this.options.iFrameClass) { + this.editor.addClass(this.options.iFrameClass); + } else { + this.editor.css({ + minHeight: (newY - 6).toString() + "px", + // fix for issue 12 ( http://github.com/akzhan/jwysiwyg/issues/issue/12 ) + width: (newX > 50) ? newX.toString() + "px" : "" + }); + if (is_msie && parseInt(is_version, 10) < 7) { + this.editor.css("height", newY.toString() + "px"); + } + } + /** + * Automagically add id to iframe if textarea has its own when possible + * ( http://github.com/akzhan/jwysiwyg/issues/245 ) + */ + if (element.id) { + var proposedId = element.id + '-wysiwyg-iframe'; + if (! document.getElementById(proposedId)) { + this.editor.attr('id', proposedId); + } + } + + /** + * http://code.google.com/p/jwysiwyg/issues/detail?id=96 + */ + this.editor.attr("tabindex", $(element).attr("tabindex")); + + this.element = $("
    ").addClass("wysiwyg"); + + if (!this.options.iFrameClass) { + this.element.css({ + width: (newX > 0) ? newX.toString() + "px" : "100%" + }); + } + + $(element).hide().before(this.element); + + this.viewHTML = false; + + /** + * @link http://code.google.com/p/jwysiwyg/issues/detail?id=52 + */ + this.initialContent = $(element).val(); + this.ui.initFrame(); + + if (this.options.resizeOptions && $.fn.resizable) { + this.element.resizable($.extend(true, { + alsoResize: this.editor + }, this.options.resizeOptions)); + } + + if (this.options.autoSave) { + $form.bind("submit.wysiwyg", function () { self.autoSaveFunction(); }); + } + + $form.bind("reset.wysiwyg", function () { self.resetFunction(); }); + }; + + this.ui.initFrame = function () { + var self = this.self, + stylesheet, + growHandler, + saveHandler; + + self.ui.appendControls(); + self.element.append(self.ui.toolbar) + .append($("
    ") + .css({ + clear: "both" + })) + .append(self.editor); + + self.editorDoc = self.innerDocument(); + + if (self.isDestroyed) { + return null; + } + + self.ui.designMode(); + self.editorDoc.open(); + self.editorDoc.write( + self.options.html + /** + * @link http://code.google.com/p/jwysiwyg/issues/detail?id=144 + */ + .replace(/INITIAL_CONTENT/, function () { return self.wrapInitialContent(); }) + ); + self.editorDoc.close(); + + $.wysiwyg.plugin.bind(self); + + $(self.editorDoc).trigger("initFrame.wysiwyg"); + + $(self.editorDoc).bind("click.wysiwyg", function (event) { + self.ui.checkTargets(event.target ? event.target : event.srcElement); + }); + + /** + * @link https://github.com/akzhan/jwysiwyg/issues/251 + */ + setInterval(function () { + var offset = null; + + try { + var range = self.getInternalRange(); + if (range) { + offset = { + range: range, + parent: is_msie ? range.parentElement() : range.endContainer.parentNode, + width: (is_msie ? range.boundingWidth : range.startOffset - range.endOffset) || 0 + }; + } + } + catch (e) { console.error(e); } + + if (offset && offset.width == 0 && !self.editorDoc.rememberCommand) { + self.ui.checkTargets(offset.parent); + } + }, 400); + + /** + * @link http://code.google.com/p/jwysiwyg/issues/detail?id=20 + * @link https://github.com/akzhan/jwysiwyg/issues/330 + */ + $(self.original).focus(function () { + if ($(this).filter(":visible").length === 0 || is_opera) { + return; + } + self.ui.focus(); + }); + + $(self.editorDoc).keydown(function (event) { + var emptyContentRegex; + if (event.keyCode === 8) { // backspace + emptyContentRegex = /^<([\w]+)[^>]*>()?<\/\1>$/; + if (emptyContentRegex.test(self.getContent())) { // if content is empty + event.stopPropagation(); // prevent remove single empty tag + return false; + } + } + + self.editorDoc.rememberCommand = false; + return true; + }); + + if (!is_msie) { + $(self.editorDoc).keydown(function (event) { + var controlName; + var control; + + /* Meta for Macs. tom@punkave.com */ + if (event.ctrlKey || event.metaKey) { + for (controlName in self.options.controls) { + control = self.options.controls[controlName]; + if (control.hotkey && control.hotkey.ctrl) { + if (event.keyCode === control.hotkey.key) { + self.triggerControl.apply(self, [controlName, control]); + + return false; + } + } + } + } + return true; + }); + } else if (self.options.brIE) { + $(self.editorDoc).keydown(function (event) { + if (event.keyCode === 13) { + var rng = self.getRange(); + rng.pasteHTML("
    "); + rng.collapse(false); + rng.select(); + + return false; + } + + return true; + }); + } + + if (self.options.plugins.rmFormat.rmMsWordMarkup) { + $(self.editorDoc).bind("keyup.wysiwyg", function (event) { + if (event.ctrlKey || event.metaKey) { + // CTRL + V (paste) + if (86 === event.keyCode) { + if ($.wysiwyg.rmFormat) { + if ("object" === typeof (self.options.plugins.rmFormat.rmMsWordMarkup)) { + $.wysiwyg.rmFormat.run(self, {rules: { msWordMarkup: self.options.plugins.rmFormat.rmMsWordMarkup }}); + } else { + $.wysiwyg.rmFormat.run(self, {rules: { msWordMarkup: { enabled: true }}}); + } + } + } + } + }); + } + + if (self.options.autoSave) { + $(self.editorDoc).keydown(function () { self.autoSaveFunction(); }) + .keyup(function () { self.autoSaveFunction(); }) + .mousedown(function () { self.autoSaveFunction(); }) + .bind($.support.noCloneEvent ? "input.wysiwyg" : "paste.wysiwyg", function () { self.autoSaveFunction(); }); + } + + if (self.options.autoGrow) { + if (self.options.initialMinHeight !== null) { + self.ui.initialHeight = self.options.initialMinHeight; + } else { + self.ui.initialHeight = $(self.editorDoc).height(); + } + $(self.editorDoc.body).css("border", "1px solid white"); // cancel margin collapsing + + growHandler = function () { + self.ui.grow(); + }; + + $(self.editorDoc).keyup(growHandler); + $(self.editorDoc).bind("editorRefresh.wysiwyg", growHandler); + + // fix when content height > textarea height + self.ui.grow(); + } + + if (self.options.css) { + if (String === self.options.css.constructor) { + if (is_msie) { + stylesheet = self.editorDoc.createStyleSheet(self.options.css); + $(stylesheet).attr({ + "media": "all" + }); + } else { + stylesheet = $("").attr({ + "href": self.options.css, + "media": "all", + "rel": "stylesheet", + "type": "text/css" + }); + + $(self.editorDoc).find("head").append(stylesheet); + } + } else { + self.timers.initFrame_Css = window.setTimeout(function () { + $(self.editorDoc.body).css(self.options.css); + }, 0); + } + } + + if (self.initialContent.length === 0) { + if ("function" === typeof (self.options.initialContent)) { + self.setContent(self.options.initialContent()); + } else { + self.setContent(self.options.initialContent); + } + } + + if (self.options.maxLength > 0) { + $(self.editorDoc).keydown(function (event) { + if ($(self.editorDoc).text().length >= self.options.maxLength && $.inArray(event.which, self.validKeyCodes) === -1) { + event.preventDefault(); + } + }); + } + + // Support event callbacks + $.each(self.options.events, function (key, handler) { + $(self.editorDoc).bind(key + ".wysiwyg", function (event) { + // Trigger event handler, providing the event and api to + // support additional functionality. + handler.apply(self.editorDoc, [event, self]); + }); + }); + + // restores selection properly on focus + if (is_msie) { + // Event chain: beforedeactivate => focusout => blur. + // Focusout & blur fired too late to handle internalRange() in dialogs. + // When clicked on input boxes both got range = null + $(self.editorDoc).bind("beforedeactivate.wysiwyg", function () { + self.savedRange = self.getInternalRange(); + }); + } else { + $(self.editorDoc).bind("blur.wysiwyg", function () { + self.savedRange = self.getInternalRange(); + }); + } + + $(self.editorDoc.body).addClass("wysiwyg"); + if (self.options.events && self.options.events.save) { + saveHandler = self.options.events.save; + + $(self.editorDoc).bind("keyup.wysiwyg", saveHandler); + $(self.editorDoc).bind("change.wysiwyg", saveHandler); + + if ($.support.noCloneEvent) { + $(self.editorDoc).bind("input.wysiwyg", saveHandler); + } else { + $(self.editorDoc).bind("paste.wysiwyg", saveHandler); + $(self.editorDoc).bind("cut.wysiwyg", saveHandler); + } + } + + /** + * XHTML5 {@link https://github.com/akzhan/jwysiwyg/issues/152} + */ + if (self.options.xhtml5 && self.options.unicode) { + var replacements = {ne:8800,le:8804,para:182,xi:958,darr:8595,nu:957,oacute:243,Uacute:218,omega:969,prime:8242,pound:163,igrave:236,thorn:254,forall:8704,emsp:8195,lowast:8727,brvbar:166,alefsym:8501,nbsp:160,delta:948,clubs:9827,lArr:8656,Omega:937,Auml:196,cedil:184,and:8743,plusmn:177,ge:8805,raquo:187,uml:168,equiv:8801,laquo:171,rdquo:8221,Epsilon:917,divide:247,fnof:402,chi:967,Dagger:8225,iacute:237,rceil:8969,sigma:963,Oslash:216,acute:180,frac34:190,lrm:8206,upsih:978,Scaron:352,part:8706,exist:8707,nabla:8711,image:8465,prop:8733,zwj:8205,omicron:959,aacute:225,Yuml:376,Yacute:221,weierp:8472,rsquo:8217,otimes:8855,kappa:954,thetasym:977,harr:8596,Ouml:214,Iota:921,ograve:242,sdot:8901,copy:169,oplus:8853,acirc:226,sup:8835,zeta:950,Iacute:205,Oacute:211,crarr:8629,Nu:925,bdquo:8222,lsquo:8216,apos:39,Beta:914,eacute:233,egrave:232,lceil:8968,Kappa:922,piv:982,Ccedil:199,ldquo:8220,Xi:926,cent:162,uarr:8593,hellip:8230,Aacute:193,ensp:8194,sect:167,Ugrave:217,aelig:230,ordf:170,curren:164,sbquo:8218,macr:175,Phi:934,Eta:919,rho:961,Omicron:927,sup2:178,euro:8364,aring:229,Theta:920,mdash:8212,uuml:252,otilde:245,eta:951,uacute:250,rArr:8658,nsub:8836,agrave:224,notin:8713,ndash:8211,Psi:936,Ocirc:212,sube:8838,szlig:223,micro:181,not:172,sup1:185,middot:183,iota:953,ecirc:234,lsaquo:8249,thinsp:8201,sum:8721,ntilde:241,scaron:353,cap:8745,atilde:227,lang:10216,__replacement:65533,isin:8712,gamma:947,Euml:203,ang:8736,upsilon:965,Ntilde:209,hearts:9829,Alpha:913,Tau:932,spades:9824,dagger:8224,THORN:222,"int":8747,lambda:955,Eacute:201,Uuml:220,infin:8734,rlm:8207,Aring:197,ugrave:249,Egrave:200,Acirc:194,rsaquo:8250,ETH:208,oslash:248,alpha:945,Ograve:210,Prime:8243,mu:956,ni:8715,real:8476,bull:8226,beta:946,icirc:238,eth:240,prod:8719,larr:8592,ordm:186,perp:8869,Gamma:915,reg:174,ucirc:251,Pi:928,psi:968,tilde:732,asymp:8776,zwnj:8204,Agrave:192,deg:176,AElig:198,times:215,Delta:916,sim:8764,Otilde:213,Mu:924,uArr:8657,circ:710,theta:952,Rho:929,sup3:179,diams:9830,tau:964,Chi:935,frac14:188,oelig:339,shy:173,or:8744,dArr:8659,phi:966,iuml:239,Lambda:923,rfloor:8971,iexcl:161,cong:8773,ccedil:231,Icirc:206,frac12:189,loz:9674,rarr:8594,cup:8746,radic:8730,frasl:8260,euml:235,OElig:338,hArr:8660,Atilde:195,Upsilon:933,there4:8756,ouml:246,oline:8254,Ecirc:202,yacute:253,auml:228,permil:8240,sigmaf:962,iquest:191,empty:8709,pi:960,Ucirc:219,supe:8839,Igrave:204,yen:165,rang:10217,trade:8482,lfloor:8970,minus:8722,Zeta:918,sub:8834,epsilon:949,yuml:255,Sigma:931,Iuml:207,ocirc:244}; + self.events.bind("getContent", function (text) { + return text.replace(/&(?:amp;)?(?!amp|lt|gt|quot)([a-z][a-z0-9]*);/gi, function (str, p1) { + if (!replacements[p1]) { + p1 = p1.toLowerCase(); + if (!replacements[p1]) { + p1 = "__replacement"; + } + } + + var num = replacements[p1]; + /* Numeric return if ever wanted: return replacements[p1] ? "&#"+num+";" : ""; */ + return String.fromCharCode(num); + }); + }); + } + $(self.original).trigger('ready.jwysiwyg', [self.editorDoc, self]); + }; + + this.innerDocument = function () { + var element = this.editor.get(0); + + if (element.nodeName.toLowerCase() === "iframe") { + if (element.contentDocument) { // Gecko + return element.contentDocument; + } else if (element.contentWindow) { // IE + return element.contentWindow.document; + } + + if (this.isDestroyed) { + return null; + } + + console.error("Unexpected error in innerDocument"); + + /* + return ( is_msie ) + ? document.frames[element.id].document + : element.contentWindow.document // contentDocument; + */ + } + + return element; + }; + + this.insertHtml = function (szHTML) { + var img, range; + + if (!szHTML || szHTML.length === 0) { + return this; + } + + if (is_msie) { + this.ui.focus(); + this.editorDoc.execCommand("insertImage", false, "#jwysiwyg#"); + img = this.getElementByAttributeValue("img", "src", "#jwysiwyg#"); + if (img) { + $(img).replaceWith(szHTML); + } + } else { + if (is_mozilla) { // @link https://github.com/akzhan/jwysiwyg/issues/50 + if (1 === $(szHTML).length) { + range = this.getInternalRange(); + range.deleteContents(); + range.insertNode($(szHTML).get(0)); + } else { + this.editorDoc.execCommand("insertHTML", false, szHTML); + } + } else { + if (!this.editorDoc.execCommand("insertHTML", false, szHTML)) { + this.editor.focus(); + /* :TODO: place caret at the end + if (window.getSelection) { + } else { + } + this.editor.focus(); + */ + this.editorDoc.execCommand("insertHTML", false, szHTML); + } + } + } + + this.saveContent(); + + return this; + }; + + //check allowed properties + this.parseControls = function () { + var self = this; + + $.each(this.options.controls, function (controlName, control) { + $.each(control, function (propertyName) { + if (-1 === $.inArray(propertyName, self.availableControlProperties)) { + throw controlName + '["' + propertyName + '"]: property "' + propertyName + '" not exists in Wysiwyg.availableControlProperties'; + } + }); + }); + + if (this.options.parseControls) { //user callback + return this.options.parseControls.call(this); + } + + return this.options.controls; + }; + + this.removeFormat = function () { + if (is_msie) { + this.ui.focus(); + } + + if (this.options.removeHeadings) { + this.editorDoc.execCommand("formatBlock", false, "

    "); // remove headings + } + + this.editorDoc.execCommand("removeFormat", false, null); + this.editorDoc.execCommand("unlink", false, null); + + if ($.wysiwyg.rmFormat && $.wysiwyg.rmFormat.enabled) { + if ("object" === typeof (this.options.plugins.rmFormat.rmMsWordMarkup)) { + $.wysiwyg.rmFormat.run(this, {rules: { msWordMarkup: this.options.plugins.rmFormat.rmMsWordMarkup }}); + } else { + $.wysiwyg.rmFormat.run(this, {rules: { msWordMarkup: { enabled: true }}}); + } + } + + return this; + }; + + this.ui.removeHoverClass = function () { + $(this).removeClass("wysiwyg-button-hover"); + }; + + this.resetFunction = function () { + this.setContent(this.initialContent); + }; + + this.saveContent = function () { + if (this.viewHTML) + { + return; // no need + } + if (this.original) { + var content, newContent; + + content = this.getContent(); + + if (this.options.rmUnwantedBr) { + content = content.replace(/$/, ""); + } + + if (this.options.replaceDivWithP) { + newContent = $("

    ").addClass("temp").append(content); + + newContent.children("div").each(function () { + var element = $(this), p = element.find("p"), i; + + if (0 === p.length) { + p = $("

    "); + + if (this.attributes.length > 0) { + for (i = 0; i < this.attributes.length; i += 1) { + p.attr(this.attributes[i].name, element.attr(this.attributes[i].name)); + } + } + + p.append(element.html()); + + element.replaceWith(p); + } + }); + + content = newContent.html(); + } + + $(this.original).val(content).change(); + + if (this.options.events && this.options.events.save) { + this.options.events.save.call(this); + } + } + + return this; + }; + + this.setContent = function (newContent) { + this.editorDoc.body.innerHTML = cleanHTML(newContent); + this.saveContent(); + + return this; + }; + + this.triggerControl = function (name, control) { + var cmd = control.command || name, //command directly for designMode=on iframe (this.editorDoc) + args = control["arguments"] || []; + + if (control.exec) { + control.exec.apply(this); //custom exec function in control, allows DOM changing + } else { + this.ui.focus(); + this.ui.withoutCss(); //disable style="" attr inserting in mozzila's designMode + // when click , or got "Access to XPConnect service denied" code: "1011" + // in Firefox untrusted JavaScript is not allowed to access the clipboard + try { + this.editorDoc.execCommand(cmd, false, args); + } catch (e) { + console.error(e); + } + } + + if (this.options.autoSave) { + this.autoSaveFunction(); + } + }; + + this.triggerControlCallback = function (name) { + $(window).trigger("trigger-" + name + ".wysiwyg", [this]); + }; + + this.ui.withoutCss = function () { + var self = this.self; + + if (is_mozilla) { + try { + self.editorDoc.execCommand("styleWithCSS", false, false); + } catch (e) { + try { + self.editorDoc.execCommand("useCSS", false, true); + } catch (e2) { + } + } + } + + return self; + }; + + this.wrapInitialContent = function () { + var content = this.initialContent, + found = content.match(/<\/?p>/gi); + + if (!found) { + return "

    " + content + "

    "; + } else { + // :TODO: checking/replacing + } + + return content; + }; + } + + /* + * Wysiwyg namespace: public properties and methods + */ + $.wysiwyg = { + messages: { + noObject: "Something goes wrong, check object" + }, + + /** + * Custom control support by Alec Gorge ( http://github.com/alecgorge ) + */ + addControl: function (object, name, settings) { + return object.each(function () { + var oWysiwyg = $(this).data("wysiwyg"), + customControl = {}, + toolbar; + + if (!oWysiwyg) { + return this; + } + + customControl[name] = $.extend(true, {visible: true, custom: true}, settings); + $.extend(true, oWysiwyg.options.controls, customControl); + + // render new toolbar + toolbar = $(oWysiwyg.options.toolbarHtml); + oWysiwyg.ui.toolbar.replaceWith(toolbar); + oWysiwyg.ui.toolbar = toolbar; + oWysiwyg.ui.appendControls(); + }); + }, + + clear: function (object) { + return object.each(function () { + var oWysiwyg = $(this).data("wysiwyg"); + + if (!oWysiwyg) { + return this; + } + + oWysiwyg.setContent(""); + }); + }, + + console: console, // let our console be available for extensions + + destroy: function (object) { + return object.each(function () { + var oWysiwyg = $(this).data("wysiwyg"); + + if (!oWysiwyg) { + return this; + } + + oWysiwyg.destroy(); + }); + }, + + "document": function (object) { + // no chains because of return + var oWysiwyg = object.data("wysiwyg"); + + if (!oWysiwyg) { + return undefined; + } + + return $(oWysiwyg.editorDoc); + }, + + getContent: function (object) { + // no chains because of return + var oWysiwyg = object.data("wysiwyg"); + + if (!oWysiwyg) { + return undefined; + } + + return oWysiwyg.getContent(); + }, + + getSelection: function (object) { + // no chains because of return + var oWysiwyg = object.data("wysiwyg"); + + if (!oWysiwyg) { + return undefined; + } + + return oWysiwyg.getRangeText(); + }, + + init: function (object, options) { + return object.each(function () { + var opts = $.extend(true, {}, options), + obj; + + // :4fun: + // remove this textarea validation and change line in this.saveContent function + // $(this.original).val(content); to $(this.original).html(content); + // now you can make WYSIWYG editor on h1, p, and many more tags + if (("textarea" !== this.nodeName.toLowerCase()) || $(this).data("wysiwyg")) { + return; + } + + obj = new Wysiwyg(); + obj.init(this, opts); + $.data(this, "wysiwyg", obj); + + $(obj.editorDoc).trigger("afterInit.wysiwyg"); + }); + }, + + insertHtml: function (object, szHTML) { + return object.each(function () { + var oWysiwyg = $(this).data("wysiwyg"); + + if (!oWysiwyg) { + return this; + } + + oWysiwyg.insertHtml(szHTML); + }); + }, + + plugin: { + listeners: {}, + + bind: function (Wysiwyg) { + var self = this; + + $.each(this.listeners, function (action, handlers) { + var i, plugin; + + for (i = 0; i < handlers.length; i += 1) { + plugin = self.parseName(handlers[i]); + + $(Wysiwyg.editorDoc).bind(action + ".wysiwyg", {plugin: plugin}, function (event) { + $.wysiwyg[event.data.plugin.name][event.data.plugin.method].apply($.wysiwyg[event.data.plugin.name], [Wysiwyg]); + }); + } + }); + }, + + exists: function (name) { + var plugin; + + if ("string" !== typeof (name)) { + return false; + } + + plugin = this.parseName(name); + + if (!$.wysiwyg[plugin.name] || !$.wysiwyg[plugin.name][plugin.method]) { + return false; + } + + return true; + }, + + listen: function (action, handler) { + var plugin; + + plugin = this.parseName(handler); + + if (!$.wysiwyg[plugin.name] || !$.wysiwyg[plugin.name][plugin.method]) { + return false; + } + + if (!this.listeners[action]) { + this.listeners[action] = []; + } + + this.listeners[action].push(handler); + + return true; + }, + + parseName: function (name) { + var elements; + + if ("string" !== typeof (name)) { + return false; + } + + elements = name.split("."); + + if (2 > elements.length) { + return false; + } + + return {name: elements[0], method: elements[1]}; + }, + + register: function (data) { + if (!data.name) { + console.error("Plugin name missing"); + } + + $.each($.wysiwyg, function (pluginName) { + if (pluginName === data.name) { + console.error("Plugin with name '" + data.name + "' was already registered"); + } + }); + + $.wysiwyg[data.name] = data; + + return true; + } + }, + + removeFormat: function (object) { + return object.each(function () { + var oWysiwyg = $(this).data("wysiwyg"); + + if (!oWysiwyg) { + return this; + } + + oWysiwyg.removeFormat(); + }); + }, + + save: function (object) { + return object.each(function () { + var oWysiwyg = $(this).data("wysiwyg"); + + if (!oWysiwyg) { + return this; + } + + oWysiwyg.saveContent(); + }); + }, + + selectAll: function (object) { + var oWysiwyg = object.data("wysiwyg"), oBody, oRange, selection; + + if (!oWysiwyg) { + return this; + } + + oBody = oWysiwyg.editorDoc.body; + if (window.getSelection) { + selection = oWysiwyg.getInternalSelection(); + selection.selectAllChildren(oBody); + } else { + oRange = oBody.createTextRange(); + oRange.moveToElementText(oBody); + oRange.select(); + } + }, + + setContent: function (object, newContent) { + return object.each(function () { + var oWysiwyg = $(this).data("wysiwyg"); + + if (!oWysiwyg) { + return this; + } + + oWysiwyg.setContent(newContent); + }); + }, + + triggerControl: function (object, controlName) { + return object.each(function () { + var oWysiwyg = $(this).data("wysiwyg"); + + if (!oWysiwyg) { + return this; + } + + if (!oWysiwyg.controls[controlName]) { + console.error("Control '" + controlName + "' not exists"); + } + + oWysiwyg.triggerControl.apply(oWysiwyg, [controlName, oWysiwyg.controls[controlName]]); + }); + }, + + support: { + prop: supportsProp + }, + + utils: { + extraSafeEntities: [["<", ">", "'", '"', " "], [32]], + + encodeEntities: function (str) { + var self = this, aStr, aRet = []; + + if (this.extraSafeEntities[1].length === 0) { + $.each(this.extraSafeEntities[0], function (i, ch) { + self.extraSafeEntities[1].push(ch.charCodeAt(0)); + }); + } + aStr = str.split(""); + $.each(aStr, function (i) { + var iC = aStr[i].charCodeAt(0); + if ($.inArray(iC, self.extraSafeEntities[1]) && (iC < 65 || iC > 127 || (iC > 90 && iC < 97))) { + aRet.push('&#' + iC + ';'); + } else { + aRet.push(aStr[i]); + } + }); + + return aRet.join(''); + } + } + }; + + /** + * Unifies dialog methods to allow custom implementations + * + * Events: + * * afterOpen + * * beforeShow + * * afterShow + * * beforeHide + * * afterHide + * * beforeClose + * * afterClose + * + * Example: + * var dialog = new ($.wysiwyg.dialog)($('#idToTextArea').data('wysiwyg'), {"title": "Test", "content": "form data, etc."}); + * + * dialog.bind("afterOpen", function () { alert('you should see a dialog behind this one!'); }); + * + * dialog.open(); + * + * + */ + $.wysiwyg.dialog = function (jWysiwyg, opts) { + + var theme = (jWysiwyg && jWysiwyg.options && jWysiwyg.options.dialog) ? jWysiwyg.options.dialog : (opts.theme ? opts.theme : "default"), + obj = new $.wysiwyg.dialog.createDialog(theme), + that = this, + $that = $(that); + + this.options = { + "modal": true, + "draggable": true, + "title": "Title", + "content": "Content", + "width": "auto", + "height": "auto", + "zIndex": 2000, + "open": false, + "close": false + }; + + this.isOpen = false; + + $.extend(this.options, opts); + + this.object = obj; + + // Opens a dialog with the specified content + this.open = function () { + this.isOpen = true; + + obj.init.apply(that, []); + var $dialog = obj.show.apply(that, []); + + $that.trigger("afterOpen", [$dialog]); + + }; + + this.show = function () { + this.isOpen = true; + + $that.trigger("beforeShow"); + + var $dialog = obj.show.apply(that, []); + + $that.trigger("afterShow"); + }; + + this.hide = function () { + this.isOpen = false; + + $that.trigger("beforeHide"); + + var $dialog = obj.hide.apply(that, []); + + $that.trigger("afterHide", [$dialog]); + }; + + // Closes the dialog window. + this.close = function () { + this.isOpen = false; + + var $dialog = obj.hide.apply(that, []); + + $that.trigger("beforeClose", [$dialog]); + + obj.destroy.apply(that, []); + + $that.trigger("afterClose", [$dialog]); + + jWysiwyg.ui.focus(); + }; + + if (this.options.open) { + $that.bind("afterOpen", this.options.open); + } + if (this.options.close) { + $that.bind("afterClose", this.options.close); + } + + return this; + }; + + // "Static" Dialog methods. + $.extend(true, $.wysiwyg.dialog, { + _themes : {}, // sample {"Theme Name": object} + _theme : "", // the current theme + + register : function(name, obj) { + $.wysiwyg.dialog._themes[name] = obj; + }, + + deregister : function (name) { + delete $.wysiwyg.dialog._themes[name]; + }, + + createDialog : function (name) { + return new ($.wysiwyg.dialog._themes[name]); + }, + + getDimensions : function () { + var width = document.body.scrollWidth, + height = document.body.scrollHeight; + + if (is_opera) { + height = Math.max( + $(document).height(), + $(window).height(), + document.documentElement.clientHeight); + } + + return [width, height]; + } + }); + + $(function () { // need access to jQuery UI stuff. + if (jQuery.ui) { + $.wysiwyg.dialog.register("jqueryui", function () { + var that = this; + + this._$dialog = null; + + this.init = function() { + var abstractDialog = this, + content = this.options.content; + + if (typeof content === 'object') { + if (typeof content.html === 'function') { + content = content.html(); + } else if(typeof content.toString === 'function') { + content = content.toString(); + } + } + + that._$dialog = $('
    ').attr('title', this.options.title).html(content); + + var dialogHeight = this.options.height == 'auto' ? 300 : this.options.height, + dialogWidth = this.options.width == 'auto' ? 450 : this.options.width; + + // console.log(that._$dialog); + + that._$dialog.dialog({ + modal: this.options.modal, + draggable: this.options.draggable, + height: dialogHeight, + width: dialogWidth + }); + + return that._$dialog; + }; + + this.show = function () { + that._$dialog.dialog("open"); + return that._$dialog; + }; + + this.hide = function () { + that._$dialog.dialog("close"); + return that._$dialog; + }; + + this.destroy = function() { + that._$dialog.dialog("destroy"); + return that._$dialog; + }; + }); + } + + $.wysiwyg.dialog.register("default", function () { + var that = this; + + this._$dialog = null; + + this.init = function() { + var abstractDialog = this, + content = this.options.content; + + if (typeof content === 'object') { + if(typeof content.html === 'function') { + content = content.html(); + } + else if(typeof content.toString === 'function') { + content = content.toString(); + } + } + + that._$dialog = $('
    ').css({"z-index": this.options.zIndex}); + + var $topbar = $('
    '+this.options.title+'
    '); + var $link = $('X'); + + $link.click(function () { + abstractDialog.close(); // this is important it makes sure that is close from the abstract $.wysiwyg.dialog instace, not just locally + return false; + }); + + $topbar.find('.wysiwyg-dialog-close-wrapper').prepend($link); + + var $dcontent = $('
    '+content+'
    '); + + that._$dialog.append($topbar).append($dcontent); + + // Set dialog's height & width, and position it correctly: + var dialogHeight = this.options.height == 'auto' ? 300 : this.options.height, + dialogWidth = this.options.width == 'auto' ? 450 : this.options.width; + that._$dialog.hide().css({ + "width": dialogWidth, + "height": dialogHeight, + "left": (($(window).width() - dialogWidth) / 2), + "top": (($(window).height() - dialogHeight) / 3) + }); + + $("body").append(that._$dialog); + + return that._$dialog; + }; + + this.show = function () { + + // Modal feature: + if (this.options.modal) { + var dimensions = $.wysiwyg.dialog.getDimensions(), + wrapper = $('
    ') + .css({"width": dimensions[0], "height": dimensions[1]}); + that._$dialog.wrap(wrapper); + } + + // Draggable feature: + if (this.options.draggable) { + + var mouseDown = false; + + that._$dialog.find("div.wysiwyg-dialog-topbar").bind("mousedown", function (e) { + e.preventDefault(); + $(this).css({ "cursor": "move" }); + var $topbar = $(this), + _dialog = $(this).parents(".wysiwyg-dialog"), + offsetX = (e.pageX - parseInt(_dialog.css("left"), 10)), + offsetY = (e.pageY - parseInt(_dialog.css("top"), 10)); + mouseDown = true; + $(this).css({ "cursor": "move" }); + + $(document).bind("mousemove", function (e) { + e.preventDefault(); + if (mouseDown) { + _dialog.css({ + "top": (e.pageY - offsetY), + "left": (e.pageX - offsetX) + }); + } + }).bind("mouseup", function (e) { + e.preventDefault(); + mouseDown = false; + $topbar.css({ "cursor": "auto" }); + $(document).unbind("mousemove").unbind("mouseup"); + }); + + }); + } + + that._$dialog.show(); + return that._$dialog; + + }; + + this.hide = function () { + that._$dialog.hide(); + return that._$dialog; + }; + + this.destroy = function() { + + // Modal feature: + if (this.options.modal) { + that._$dialog.unwrap(); + } + + // Draggable feature: + if (this.options.draggable) { + that._$dialog.find("div.wysiwyg-dialog-topbar").unbind("mousedown"); + } + + that._$dialog.remove(); + return that._$dialog; + }; + }); + }); + // end Dialog + + $.fn.wysiwyg = function (method) { + var args = arguments, plugin; + + if ("undefined" !== typeof $.wysiwyg[method]) { + // set argument object to undefined + args = Array.prototype.concat.call([args[0]], [this], Array.prototype.slice.call(args, 1)); + return $.wysiwyg[method].apply($.wysiwyg, Array.prototype.slice.call(args, 1)); + } else if ("object" === typeof method || !method) { + Array.prototype.unshift.call(args, this); + return $.wysiwyg.init.apply($.wysiwyg, args); + } else if ($.wysiwyg.plugin.exists(method)) { + plugin = $.wysiwyg.plugin.parseName(method); + args = Array.prototype.concat.call([args[0]], [this], Array.prototype.slice.call(args, 1)); + return $.wysiwyg[plugin.name][plugin.method].apply($.wysiwyg[plugin.name], Array.prototype.slice.call(args, 1)); + } else { + console.error("Method '" + method + "' does not exist on jQuery.wysiwyg.\nTry to include some extra controls or plugins"); + } + }; + + $.fn.getWysiwyg = function () { + return this.data("wysiwyg"); + }; + + function cleanHTML(html, striptags){ + if(striptags) html = html.replace(/(<([^>]+)>)/ig,""); + var pres = html.match(/]*>([\s\S]*?)<\/pre>/gi); + if(pres){ + for(i=0;i"']))+.)["']?/gi); + if(att){ + $.each(att, function(i,e){ +/* + if(!/(href|src|colspan|rowspan)/.test(e)){ + html = html.replace(e,''); + } +*/ + if(!/(href|src)/.test(e)){ + html = html.replace(e,''); + } + }); + } + //html = html.replace(/\n\n+/g,'

    '); + //html = html.replace(/\s+/g,' '); + html = html.replace(/

    <\/p>/g,' '); + if(pres){ + for(i=0;i']; + + colCount = parseInt(colCount, 10); + rowCount = parseInt(rowCount, 10); + + if (filler === null) { + filler = " "; + } + filler = "" + filler + ""; + + for (i = rowCount; i > 0; i -= 1) { + html.push(""); + for (j = colCount; j > 0; j -= 1) { + html.push(filler); + } + html.push(""); + } + html.push(""); + + return this.insertHtml(html.join("")); + }; + + /* + * Wysiwyg namespace: public properties and methods + */ + $.wysiwyg.controls.table = function (Wysiwyg) { + var adialog, dialog, colCount, rowCount, formTableHtml, dialogReplacements, key, translation, regexp; + + dialogReplacements = { + legend: "Insert table", + cols : "Count of columns", + rows : "Count of rows", + submit: "Insert table", + reset: "Cancel" + }; + + formTableHtml = '

    {legend}' + + '
    ' + + '
    ' + + ' ' + + '
    '; + + for (key in dialogReplacements) { + if ($.wysiwyg.i18n) { + translation = $.wysiwyg.i18n.t(dialogReplacements[key], "dialogs.table"); + + if (translation === dialogReplacements[key]) { // if not translated search in dialogs + translation = $.wysiwyg.i18n.t(dialogReplacements[key], "dialogs"); + } + + dialogReplacements[key] = translation; + } + + regexp = new RegExp("{" + key + "}", "g"); + formTableHtml = formTableHtml.replace(regexp, dialogReplacements[key]); + } + + if (!Wysiwyg.insertTable) { + Wysiwyg.insertTable = insertTable; + } + + adialog = new $.wysiwyg.dialog(Wysiwyg, { + "title" : dialogReplacements.legend, + "content" : formTableHtml, + "open" : function (e, dialog) { + dialog.find("form#wysiwyg-tableInsert").submit(function (e) { + e.preventDefault(); + rowCount = dialog.find("input[name=rowCount]").val(); + colCount = dialog.find("input[name=colCount]").val(); + + Wysiwyg.insertTable(colCount, rowCount, Wysiwyg.defaults.tableFiller); + + adialog.close(); + return false; + }); + + dialog.find("input:reset").click(function (e) { + e.preventDefault(); + adialog.close(); + return false; + }); + } + }); + + adialog.open(); + + $(Wysiwyg.editorDoc).trigger("editorRefresh.wysiwyg"); + }; + + $.wysiwyg.insertTable = function (object, colCount, rowCount, filler) { + return object.each(function () { + var Wysiwyg = $(this).data("wysiwyg"); + + if (!Wysiwyg.insertTable) { + Wysiwyg.insertTable = insertTable; + } + + if (!Wysiwyg) { + return this; + } + + Wysiwyg.insertTable(colCount, rowCount, filler); + $(Wysiwyg.editorDoc).trigger("editorRefresh.wysiwyg"); + + return this; + }); + }; +})(jQuery); + +/** + * Controls: Link plugin + * + * Depends on jWYSIWYG + * + * By: Esteban Beltran (academo) + */ +(function ($) { + "use strict"; + + if (undefined === $.wysiwyg) { + throw "wysiwyg.link.js depends on $.wysiwyg"; + } + + if (!$.wysiwyg.controls) { + $.wysiwyg.controls = {}; + } + + /* + * Wysiwyg namespace: public properties and methods + */ + $.wysiwyg.controls.link = { + init: function (Wysiwyg) { + var self = this, elements, dialog, url, a, selection, + formLinkHtml, dialogReplacements, key, translation, regexp, + baseUrl, img; + + dialogReplacements = { + legend: "Insert Link", + url : "Link URL", + title : "Link Title", + target: "Link Target", + submit: "Insert Link", + reset: "Cancel" + }; + + formLinkHtml = '
    {legend}' + + '' + + '' + + '' + + ' ' + + '
    '; + + for (key in dialogReplacements) { + if ($.wysiwyg.i18n) { + translation = $.wysiwyg.i18n.t(dialogReplacements[key], "dialogs.link"); + + if (translation === dialogReplacements[key]) { // if not translated search in dialogs + translation = $.wysiwyg.i18n.t(dialogReplacements[key], "dialogs"); + } + + dialogReplacements[key] = translation; + } + + regexp = new RegExp("{" + key + "}", "g"); + formLinkHtml = formLinkHtml.replace(regexp, dialogReplacements[key]); + } + + a = { + self: Wysiwyg.dom.getElement("a"), // link to element node + href: "http://", + title: "", + target: "" + }; + + if (a.self) { + a.href = a.self.href ? a.self.href : a.href; + a.title = a.self.title ? a.self.title : ""; + a.target = a.self.target ? a.self.target : ""; + } + + if ($.fn.dialog) { + elements = $(formLinkHtml); + elements.find("input[name=linkhref]").val(a.href); + elements.find("input[name=linktitle]").val(a.title); + elements.find("input[name=linktarget]").val(a.target); + + if (is_msie) { + try { + dialog = elements.appendTo(Wysiwyg.editorDoc.body); + } catch (err) { + dialog = elements.appendTo("body"); + } + } else { + dialog = elements.appendTo("body"); + } + + dialog.dialog({ + modal: true, + open: function (ev, ui) { + $("input:submit", dialog).click(function (e) { + e.preventDefault(); + + var url = $('input[name="linkhref"]', dialog).val(), + title = $('input[name="linktitle"]', dialog).val(), + target = $('input[name="linktarget"]', dialog).val(), + baseUrl, + img; + + if (Wysiwyg.options.controlLink.forceRelativeUrls) { + baseUrl = window.location.protocol + "//" + window.location.hostname; + if (0 === url.indexOf(baseUrl)) { + url = url.substr(baseUrl.length); + } + } + + if (a.self) { + if ("string" === typeof (url)) { + if (url.length > 0) { + // to preserve all link attributes + $(a.self).attr("href", url).attr("title", title).attr("target", target); + } else { + $(a.self).replaceWith(a.self.innerHTML); + } + } + } else { + if (is_msie) { + Wysiwyg.ui.returnRange(); + } + + //Do new link element + selection = Wysiwyg.getRangeText(); + img = Wysiwyg.dom.getElement("img"); + + if ((selection && selection.length > 0) || img) { + if (is_msie) { + Wysiwyg.ui.focus(); + } + + if ("string" === typeof (url)) { + if (url.length > 0) { + Wysiwyg.editorDoc.execCommand("createLink", false, url); + } else { + Wysiwyg.editorDoc.execCommand("unlink", false, null); + } + } + + a.self = Wysiwyg.dom.getElement("a"); + + $(a.self).attr("href", url).attr("title", title); + + /** + * @url https://github.com/akzhan/jwysiwyg/issues/16 + */ + $(a.self).attr("target", target); + } else if (Wysiwyg.options.messages.nonSelection) { + window.alert(Wysiwyg.options.messages.nonSelection); + } + } + + Wysiwyg.saveContent(); + + $(dialog).dialog("close"); + + Wysiwyg.ui.focus(); + return false; + }); + $("input:reset", dialog).click(function (e) { + e.preventDefault(); + $(dialog).dialog("close"); + Wysiwyg.ui.focus(); + }); + }, + close: function (ev, ui) { + dialog.dialog("destroy"); + dialog.remove(); + Wysiwyg.ui.focus(); + return false; + } + }); + } else { + if (a.self) { + url = window.prompt("URL", a.href); + + if (Wysiwyg.options.controlLink.forceRelativeUrls) { + baseUrl = window.location.protocol + "//" + window.location.hostname; + if (0 === url.indexOf(baseUrl)) { + url = url.substr(baseUrl.length); + } + } + + if ("string" === typeof (url)) { + if (url.length > 0) { + $(a.self).attr("href", url); + } else { + $(a.self).replaceWith(a.self.innerHTML); + } + } + } else { + //Do new link element + selection = Wysiwyg.getRangeText(); + img = Wysiwyg.dom.getElement("img"); + + if ((selection && selection.length > 0) || img) { + if (is_msie) { + Wysiwyg.ui.focus(); + Wysiwyg.editorDoc.execCommand("createLink", true, null); + } else { + url = window.prompt(dialogReplacements.url, a.href); + + if (Wysiwyg.options.controlLink.forceRelativeUrls) { + baseUrl = window.location.protocol + "//" + window.location.hostname; + if (0 === url.indexOf(baseUrl)) { + url = url.substr(baseUrl.length); + } + } + + if ("string" === typeof (url)) { + if (url.length > 0) { + Wysiwyg.editorDoc.execCommand("createLink", false, url); + } else { + Wysiwyg.editorDoc.execCommand("unlink", false, null); + } + } + } + } else if (Wysiwyg.options.messages.nonSelection) { + window.alert(Wysiwyg.options.messages.nonSelection); + } + } + + Wysiwyg.saveContent(); + } + + $(Wysiwyg.editorDoc).trigger("editorRefresh.wysiwyg"); + } + }; + + $.wysiwyg.createLink = function (object, url, title) { + return object.each(function () { + var oWysiwyg = $(this).data("wysiwyg"), + selection; + + if (!oWysiwyg) { + return this; + } + + if (!url || url.length === 0) { + return this; + } + + selection = oWysiwyg.getRangeText(); + // ability to link selected img - just hack + var internalRange = oWysiwyg.getInternalRange(); + var isNodeSelected = false; + if (internalRange && internalRange.extractContents) { + var rangeContents = internalRange.cloneContents(); + if (rangeContents!=null && rangeContents.childNodes && rangeContents.childNodes.length>0) + isNodeSelected = true; + } + + if ( (selection && selection.length > 0) || isNodeSelected ) { + if (is_msie) { + oWysiwyg.ui.focus(); + } + oWysiwyg.editorDoc.execCommand("unlink", false, null); + oWysiwyg.editorDoc.execCommand("createLink", false, url); + } else { + if (title) { + oWysiwyg.insertHtml(''+title+''); + } else { + if (oWysiwyg.options.messages.nonSelection) + window.alert(oWysiwyg.options.messages.nonSelection); + } + } + return this; + }); + }; +})(jQuery); \ No newline at end of file diff --git a/dashboard-plus-chrome-plugin/plugins/envatitor.js b/dashboard-plus-chrome-plugin/plugins/envatitor.js new file mode 100644 index 0000000..f0786fb --- /dev/null +++ b/dashboard-plus-chrome-plugin/plugins/envatitor.js @@ -0,0 +1,384 @@ +/* + * Copyright (c) 2014 + * ================================== + * powered by revaxarts.com (http://revaxarts.com) + * original filename: envatitor.js + * filesize: 14935 Bytes + * last modified: Mon, 17 Feb 2014 09:54:26 +0100 + * + */ +(function () { + + var textarea, + username = $('#user_username').text(), + $preview, interval, livepreview = (window.dashboardplus.getCookie('envatitor_livepreview') == 'false') ? false : true, + smileys = { + 'happy': ':)', + 'sad': ':(', + 'tongue': ':P', + 'wink': ';)', + 'angry': ':x', + 'expressionless': ':|', + 'laugh': ':D', + 'puzzled': ':S', + 'cool': '8-)', + 'surprised': ':O', + 'asleep': ':asleep:', + 'bashful': ':bashful:', + 'bashfulcute': ':bashfulcute:', + 'bigevilgrin': ':bigevilgrin:', + 'bigsmile': ':bigsmile:', + 'bigwink': ':bigwink:', + 'chuckle': ':chuckle:', + 'crying': ':crying:', + 'confused': ':confused:', + 'confusedsad': ':confusedsad:', + 'dead': ':dead:', + 'delicious': ':delicious:', + 'depressed': ':depressed:', + 'evil': ':evil:', + 'evilgrin': ':evilgrin:', + 'grin': ':grin:', + 'impatient': ':impatient:', + 'inlove': ':inlove:', + 'kiss': ':kiss:', + 'mad': ':mad:', + 'nerdy': ':nerdy:', + 'notfunny': ':notfunny:', + 'ohrly': ':ohrly:', + 'reallyevil': ':reallyevil:', + 'sarcasm': ':sarcasm:', + 'shocked': ':shocked:', + 'sick': ':sick:', + 'silly': ':silly:', + 'sing': ':sing:', + 'smitten': ':smitten:', + 'smug': ':smug:', + 'stress': ':stress:', + 'sunglasses': ':sunglasses:', + 'sunglasses2': ':sunglasses2:', + 'superbashfulcute': ':superbashfulcute:', + 'tired': ':tired:', + 'whistle': ':whistle:', + 'winktongue': ':winktongue:', + 'yawn': ':yawn:', + 'zipped': ':zipped:' + }, + type; + + init(); + + + function init() { + type = getType(); + + var dofocus = false; + + var style = $(''); + style.appendTo('head'); + + if (type) { + switch (type) { + case 'newThread': + textarea = $('#thread_message_content'); + break; + case 'postReply': + textarea = $('textarea[name=content]'); + break; + case 'comment': + textarea = $('textarea#reply_text'); + dofocus = true; + break; + case 'item': + textarea = $('textarea#description'); + break; + case 'itemcomment': + textarea = $('textarea#item_comment_content'); + break; + case 'faq': + textarea = $('textarea#item_faq_answer'); + break; + default: + return false; + } + + //$(window).on('load', function(){ + UI(); + preview(); + //}); + + $('body') + .on('click', '.js-comment-new-reply-field', function(){ + textarea = $(this); + UI(); + textarea.focus(); + + }) + .on('focus', 'textarea.has-envatitor', function(){ + $('.envatitor_embeded_dropdown').slideUp(200); + $(document).bind('keyup', updatePreview); + }) + .on('blur', 'textarea.has-envatitor', function(){ + $(document).unbind('keyup', updatePreview); + }) + .on('keydown', 'textarea.has-envatitor', function(e){ + if (e.which == 13 && e.shiftKey) { + insert('', '
    \n', []); + return false; + } + }) + .on('click', '.envatitor_embeded_bar > a', function () { + var button_id = $(this).data("id"); + var start = '<' + button_id + '>'; + var end = ''; + var replaceArray = []; + + var param = ""; + if (button_id == 'a') { + param = prompt("Enter URL", "http://"); + if (param) { + start = ''; + } else { + return false; + } + } else if (button_id == 'smiley') { + $('.envatitor_embeded_smileys').show(); + $('.envatitor_embeded_uploadform').hide(); + return false; + } else if (button_id == 'img') { + $('.envatitor_embeded_uploadform').show(); + $('.envatitor_embeded_smileys').hide(); + $('#envatitor_image_url').focus(); + return false; + } + insert(start, end, replaceArray); + return false; + }) + .on('click', '.envatitor_embeded_smileys img', function () { + var code = $(this).attr('alt'); + insert(code, '', []); + $('.envatitor_embeded_dropdown').hide(); + updatePreview(); + }) + .on('click', '#envatitor_embeded_livepreview', function () { + livepreview = !livepreview; + $(this).html('livepreview is ' + (livepreview ? 'ON' : 'OFF')); + window.dashboardplus.setCookie('envatitor_livepreview', livepreview); + updatePreview(); + return false; + }); + + + if(textarea){ + if(dofocus) textarea.focus(); + } + + if (type == 'newThread') { + $('#thread_subject').on('keyup', function () { + var val = $(this).val(); + if (val != '') { + $('h1').first().text($(this).val()); + } else { + $('h1').first().text('Start new thread'); + } + }).trigger('keyup'); + } + + updatePreview(); + + } + + } + + function insert(start, end, replaceArray) { + element = textarea[0]; + if (document.selection) { + element.focus(); + sel = document.selection.createRange(); + newT = sel.text; + if (start == '
    '); + output = output.replace(/⦿/g, '\n'); + $preview.html(output); + }, 200); + } + + function getType() { + if ($('#thread_message_content').length) { + return 'newThread'; + } else if ($('#thread_reply_content').length) { + return 'postReply'; + } else if ($('textarea#reply_text').length) { + return 'comment'; + } else if ($('textarea#item_comment_content').length) { + return 'itemcomment'; + } else if ($('.js-comment-new-reply-field').length) { + return 'itemcomment'; + } else if ($('textarea#item_faq_answer').length) { + return 'faq'; + } else if ($('textarea#description').length) { + return 'item'; + } + return false; + } + + + +})(); diff --git a/dashboard-plus-chrome-plugin/plugins/gotolivepreview.js b/dashboard-plus-chrome-plugin/plugins/gotolivepreview.js new file mode 100644 index 0000000..9e52970 --- /dev/null +++ b/dashboard-plus-chrome-plugin/plugins/gotolivepreview.js @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2014 + * ================================== + * powered by revaxarts.com (http://revaxarts.com) + * original filename: gotolivepreview.js + * filesize: 1710 Bytes + * last modified: Thu, 16 May 2013 09:20:29 +0200 + * + */ +// ==UserScript== +// @name GoToLivepreview for Envato's marketplaces +// @creator userscripts@revaxarts.com +// @namespace revaxarts.com +// @description Envato Livepreviews for Thumbs +// @date 2011-11-10 +// @version 0.5 +// @include http://activeden.net/* +// @include http://themeforest.net/* +// @include http://codecanyon.net/* +// ==/UserScript== +(function () { + + + + var marketplace = location.hostname.split('.').shift(); + + $('img[data-preview-url]').each(function () { + var _this = $(this), + itemname = _this.data('itemName'); + wrapper = _this.parent().parent(); + if (!wrapper.is('.thumbnail')) return false; + + var href = wrapper.find('a').attr('href').split('?')[0], + id = href.split('/').pop(), + livepreview = href.replace(id, 'full_screen_preview/' + id); + wrapper.hover(function () { + $(this).find('a.gotolivepreview').fadeIn(100); + }, function () { + $(this).find('a.gotolivepreview').fadeOut(100); + }); + + $('', { + "class": "gotolivepreview", + title: 'Livepreview of ' + itemname, + href: livepreview + }).css({ + "position": "absolute", + "display": "block", + "border": "0 !important", + "padding": "2px 4px" + }).html('').hide().prependTo(wrapper); + + }); + + $('body').delegate('a.gotolivepreview', 'click', function (event) { + event.stopPropagation(); + event.preventDefault(); + window.open(this.href); + }); + + + + if (location.href.match(/full_screen_preview/)) { + if($.trim($('h1').html()) == 'Page Not Found'){ + location.href = location.href.replace('full_screen_preview/',''); + } + } + + + + + + +})(); \ No newline at end of file diff --git a/dashboard-plus-chrome-plugin/plugins/notification.js b/dashboard-plus-chrome-plugin/plugins/notification.js new file mode 100644 index 0000000..47869e0 --- /dev/null +++ b/dashboard-plus-chrome-plugin/plugins/notification.js @@ -0,0 +1,224 @@ +(function () { + + //"use strict" + + var notifications, + interval = 5, //check interval in minutes + $badge; + +/* + var color = {}; + var marketplace = location.hostname.split('.').shift(); + color['activeden'] = 'e86223'; + color['audiojungle'] = '65992e'; + color['themeforest'] = '69472a'; + color['videohive'] = 'f4950c'; + color['graphicriver'] = '0568b3'; + color['3docean'] = '802836'; + color['codecanyon'] = 'db592b'; + color['photodune'] = '499ba1'; + + color = color[marketplace] || '333333'; +*/ + + var color = '0084B4'; + + var init = function(){ + + var now = new Date().getTime(), + lastcheck = window.dashboardplus.getCookie('notification_lastcheck'); + + + //get saved notifications + notifications = window.dashboardplus.getCookie('notification_count'); + + //print them if some exists + if(notifications) printNotifications(); + + //clear notifications if the mark all as unread button is pressed + if(/author_dashboard/.test(location.pathname)){ + + lastcheck = 0; + + var button = $('.content-s').find('.comments-search-controls__mark-all-read').find('button'); + + if(button.length) { + + button.bind('click',function(){ + window.dashboardplus.setCookie('notification_count',0); + window.dashboardplus.setCookie('notification_lastcheck',0); + printNotifications(); + }); + +/* + $.ajax({ + url: 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js', + dataType: "script", + cache: true, + success: function () { + var plt = $('#page_load_time'), + slider = $('
    ').appendTo($('.comments-controls').eq(0)), + value = $('
    use the slider to define the time you would like to mark comments as read
    ').appendTo($('.comments-controls').eq(0)), + d = new Date(), + time = parseInt(plt.val(), 10)*1000, + mintime = time-(3.156e+10), + output = time; + + d.setTime(time); + + slider.css({ + 'border': '1px solid #ccc', + 'height': 5, + 'margin-top': 20, + 'margin-left': 8, + 'margin-right': 8 + }).slider({ + min: mintime, + max: time, + step: 3156, + value: time, + slide: function (event, ui) { + var x = (time-ui.value)/(time-mintime); + x = (Math.exp(2.77258872 * x) - 1) / 15; + + output = time-(time-mintime)*x; + + button.html((time != ui.value) ? 'Mark older than '+human_time_diff(time, output)+' as read' : 'Mark all as read'); + d.setTime(Math.round(output)); + value.html(d+''); + }, + change: function (event, ui) { + d.setTime(Math.round(output)); + plt.val(Math.round(output/1000)); + + } + }).find('a').css({ + 'border': '1px solid black', + 'height': 12, + 'width': 12, + 'top': -5, + 'margin-left': -5, + 'background-color': '#'+color, + 'display': 'block', + 'position': 'relative' + }); + value.css({ + 'font-size': 12, + 'margin-top': 10, + 'color': '#aaa', + 'text-align': 'right' + }); + + + function human_time_diff(from, to){ + var diff = ((from - to)/1000); + var str = ''; + if(diff < 60){ + return (diff)+' sec.'; + }else if(diff < 3600){ + return (diff/60).toFixed(2)+' min.'; + }else if(diff < 86400){ + return (diff/3600).toFixed(2)+' hours'; + }else if(diff < 2.63e+6){ + return (diff/86400).toFixed(2)+' days'; + } + return (diff/2.63e+6).toFixed(2)+' month'; + } + } + }); +*/ + + } //end if + + + } + + setTimeout(start,Math.max(0,interval*60000-(now-lastcheck))); + + }; + + var start = function() { + checkForNotifications(1); + setInterval(function(){ + checkForNotifications(1); + }, interval*60000); + }; + + var checkForNotifications = function(page) { + + //get the Url + $.get(getURL(page), function(response){ + + //count unread posts on the dashboard + var comment = response.match(/

    (\d+) comments? found/); + notifications = comment ? parseInt(comment[1], 10) : 0; + + //we made a check, lets save it + window.dashboardplus.setCookie('notification_lastcheck',new Date().getTime()); + + //save notifications for later + window.dashboardplus.setCookie('notification_count',notifications,365); + + //print + printNotifications(); + + }); + }; + + var printNotifications = function() { + + //badge element must be made + if(!$badge){ + $badge = $('',{ + id: 'notification_badge' + }).css({ + 'display': 'block', + 'position': 'absolute', + 'left': '8px', + 'top': '9px', + 'font-size': '10px', + 'line-height': '10px', + 'font-weight': '700', + 'padding': '4px 4px 5px', + 'text-align': 'center', + 'min-width': '10px', + 'border': '0', + 'cursor': 'pointer', + 'border-radius': '4px', + 'background-color': ' #'+color, + 'color': '#fff', + 'z-index': '5000', + 'text-decoration': 'none' + }) + .hide() + .bind('click', function(){ + location.href="/author_dashboard"; + return false; + }) + .prependTo('span.global-header-menu__link-text:last'); + + } + + //remove any (XX) from the title + document.title = document.title.replace(/^\(\d+\+?\)/,''); + + //we have notifications + if(parseInt(notifications, 10)){ + $badge.html(notifications).show(); + //prepend it to the titel + document.title = '('+notifications+') '+document.title; + }else{ + //hide badge + $badge.html(notifications).hide(); + } + + }; + + var getURL = function(page) { + return 'https://'+location.hostname+'/author_dashboard?page='+page; + }; + + init(); + + +})(); diff --git a/dashboard-plus-chrome-plugin/plugins/progressbar.js b/dashboard-plus-chrome-plugin/plugins/progressbar.js new file mode 100644 index 0000000..5cfb9fd --- /dev/null +++ b/dashboard-plus-chrome-plugin/plugins/progressbar.js @@ -0,0 +1,22 @@ +// old progres bar css incase they remove it from envato stylesheet: +// [role=progressbar]{background:#1a1a1a;border-radius:5px;display:block;height:10px;margin:5px 0;padding:3px} +// .progressbar-value{background:green;background-image:-webkit-gradient(linear, 0% 50%, 290 50%, color-stop(0%, #ff9f16), color-stop(68.96552%, #ffec16), color-stop(100%, #00af15));background-image:-webkit-linear-gradient(left, #ff9f16,#ffec16 200px,#00af15 290px);background-image:-webkit-gradient(linear, left top, right top, from(#ff9f16), color-stop(200px, #ffec16), color-stop(290px, #00af15));background-image:-webkit-linear-gradient(left, #ff9f16, #ffec16 200px, #00af15 290px);background-image:linear-gradient(left, #ff9f16,#ffec16 200px,#00af15 290px);border-radius:2px;-webkit-box-shadow:0 0 5px #fff inset;box-shadow:0 0 5px #fff inset;display:block;height:10px;text-indent:-9999px;-webkit-transition:"width",0.5s;transition:"width",0.5s}.progressbar-value.loadup{-ms-animation:loadUp 1s ease-in-out;-webkit-animation:loadUp 1s ease-in-out;animation:loadUp 1s ease-in-out;-webkit-transition:"width",0s;transition:"width",0s} + + +(function () { + + init(); + + function init(){ + + // start super secret ninja progress bar code!!! + // shhhh!!! - don't tell anyone how I figured it out. + // I think this is more accurate than the old progress bar :) + eval(function(p,a,c,k,e,d){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('c 4=$(\'.n-q\').m(\'.k-l-z-x\').h();e(!4||!4.f){4=$("a[v^=\'/t/u\']").h()}e(4.f>0){c 6=4.r().A(/(\\d+)\\s(\\w+)\\p/);c 3=o;y(6[2]){7"P":7"O":8;7"N":3+=g(6[1]);8;7"B":3+=g(6[1]*R);8;Q:3=b;8}e(3>b)3=b;$(\'<5 i="L-M" F="j"> <5 i="j-E" 9-D="\'+3+\'" 9-C="0" 9-G="H" K="J: \'+3+\'%;"> \'+3+\'% \').I(4)}',54,54,'|||percentage|progresstarget|div|history|case|break|aria||90|var||if|length|parseInt|parent|class|progressbar|item|update|find|sidebar|10|sago|right|text||upload|delete_from_|href||link|switch|deletion|match|days|valuemin|valuenow|value|role|valuemax|100|insertBefore|width|style|progress|bar|hours|minutes|minute|default|12'.split('|'),0,{})); + + + } + + + +})(); \ No newline at end of file diff --git a/dashboard-plus-chrome-plugin/plugins/quickcollection.js b/dashboard-plus-chrome-plugin/plugins/quickcollection.js new file mode 100644 index 0000000..c6a6a2d --- /dev/null +++ b/dashboard-plus-chrome-plugin/plugins/quickcollection.js @@ -0,0 +1,216 @@ +/* + * Copyright (c) 2014 + * ================================== + * powered by revaxarts.com (http://revaxarts.com) + * original filename: quickcollection.js + * filesize: 5608 Bytes + * last modified: Tue, 28 Jan 2014 11:15:03 +0100 + * + */ +(function () { + + //"use strict" + + var username = $('#user_username').text(); + + if (!username || !JSON) return false; + + var refreshindays = 1, + cont, now = new Date().getTime(), + lastcheck = window.dashboardplus.getCookie('quickcollection_lastcheck'); + + var currentid = 0; + $('#new_collection, #bookmark_form').submit(function () { + localStorage.removeItem('quickcollection'); + }); + + if (!lastcheck) { + localStorage.removeItem('quickcollection'); + window.dashboardplus.setCookie('quickcollection_lastcheck', now, refreshindays); + } + if (location.hash == '#bookmark_form') { + $('#collection_create_link').find('a').trigger('click'); + $('#name').focus(); + } + + getCollections(function (collections) { + + + var html = getHTML(collections); + + cont = $('

    ', { + 'id': 'quickcollection' + }).css({ + "position": "absolute", + "zIndex": "2000", + "background-color": '#F4F4F4', + "border": "1px solid #BBBBBB", + "text-align": "left", + "-webkit-box-shadow": "4px 4px 0 0 rgba(35, 35, 35, 0.1)", + "-moz-box-shadow": "4px 4px 0 0 rgba(35, 35, 35, 0.1)", + "box-shadow": "4px 4px 0 0 rgba(35, 35, 35, 0.1)", + "font-size": "10px", + "display": "block", + "padding": "10px", + "background": "#F4F4F4 no-repeat 95% 98%" + }).html('' + html + '').hide().appendTo('body').bind('mouseleave', function () { + $(this).stop().fadeTo(50, 0, function () { + cont.css({ + 'left': -300 + }); + }); + }).delegate('a', 'click', function () { + var _this = $(this), + collectionid = _this.data('id'); + if (collectionid) { + add(currentid, collectionid, '', function () { + //alert('Item successfully added to "'+_this.text()+'"'); + }, function () { + alert('Couldn\'t save item to "' + _this.text() + '"'); + localStorage.removeItem('quickcollection'); + _this.remove(); + }); + + } else if (_this.is('.quickcollection_new')) { + + if (name = prompt('New Collection', 'Enter Collection Name')) { + add(currentid, collectionid, name, function () { + alert('Item successfully added to new collection "' + name + '"'); + refreshcollection(); + }, function () { + alert('Couldn\'t save item to "' + name + '"'); + localStorage.removeItem('quickcollection'); + }); + } + return false + + } else if (_this.is('.quickcollection_refresh')) { + + refreshcollection(); + + } + return false; + }); + + var h = cont.height(); + + $('img[data-preview-url], .audio-container').each(function () { + var _this = $(this), + itemname = _this.data('itemName'); + wrapper = _this.parent().parent().css('position', 'relative'); + if (!wrapper.is('.thumbnail')) { + wrapper = _this.parent(); + if (!wrapper.is('.thumbnail')) { + return false; + } + } + if (wrapper.find('a').eq(0).is('.quickcollection')) return false; + var href = wrapper.find('a').attr('href').split('?')[0], + id = href.split('/').pop(); + + wrapper.hover(function () { + $(this).find('a.quickcollection').fadeIn(100); + }, function () { + $(this).find('a.quickcollection').fadeOut(100); + }); + + $('', { + "class": "quickcollection", + title: 'Bookmark "' + itemname + '"', + href: '#' + }).data('id', id).css({ + "position": "absolute", + "display": "block", + "border": "0 !important", + "background": "url(http://1.envato-static.com/assets/sprites/common-sb6532a3078-a35a2455e60b2c49e07795c07a741576.png) no-repeat -6px -2632px", + "width": 10, + "height": 16, + "zIndex": 1, + "margin-left": "16px", + "padding": "0" + }).html('').hide().prependTo(wrapper).click(function () { + var _this = $(this), + _o = _this.offset(); + currentid = _this.data('id'); + cont.css({ + 'top': _o.top - (h / 4) + 'px', + 'left': (_o.left) + 'px' + }).stop().fadeTo(200, 1); + return false; + }); + + }); + + }); + + function getHTML(collections) { + var html = 'Quickcollection | new Collection | '; + + for (name in collections) { + html += '
    ' + name + ''; + } + + return html; + + } + + + function refreshcollection() { + localStorage.removeItem('quickcollection'); + getCollections(function (collections) { + html = getHTML(collections); + cont.html(html); + }) + } + + + function getCollections(callback) { + var collections = $.parseJSON(localStorage.getItem('quickcollection')); + if (!collections) { + $.get(getURL(), function (data) { + + collections = {}; + + data = data.match(/([^<]+)/g) || []; + var count = data.length; + for (var i = 0; i < count; i++) { + collections[data[i].substr(data[i].lastIndexOf('>') + 1)] = data[i].match(/\d+/)[0]; + } + localStorage.setItem('quickcollection', JSON.stringify(collections)); + callback(collections); + + }); + } + callback(collections); + } + + function add(itemid, collectionid, collectionname, success, error) { + cont.css('background-image','url(http://2.envato-static.com/assets/common/pagination_loader-a367a90aff9ad10425e524a1867d0709.gif)'); + $.ajax('/bookmarks', { + data: { + name: collectionname, + item_id:itemid, + collection_id: collectionid + }, + type: 'POST', + cache: false, + success: function (d) { + success(d); + }, + complete: function () { + cont.css('background-image','none'); + }, + error: function (d) { + error(d); + } + + }); + }; + + function getURL() { + return '/user/' + username + '/bookmarks'; + }; + + + +})(); \ No newline at end of file diff --git a/dashboard-plus-chrome-plugin/plugins/reminder.js b/dashboard-plus-chrome-plugin/plugins/reminder.js new file mode 100644 index 0000000..617eb1b --- /dev/null +++ b/dashboard-plus-chrome-plugin/plugins/reminder.js @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2014 + * ================================== + * powered by revaxarts.com (http://revaxarts.com) + * original filename: reminder.js + * filesize: 3052 Bytes + * last modified: Thu, 12 Jun 2014 07:45:22 +0200 + * + */ +(function () { + + //"use strict" + + var d = new Date(), + currentYear = d.getFullYear(), + currentMonth = d.getMonth(), + melborntimeoffset = d.getTimezoneOffset()/60+11, + lastday = new Date(currentYear, currentMonth + 1, 0, 24-melborntimeoffset), + banner = false, + remindersat = window.dashboardplus.get('reminder','hours'), + past = window.dashboardplus.getCookie('reminder'), + timeleft = null; + + + remindersat = remindersat ? remindersat.split(',') : []; + past = past ? past.split('|') : []; + + if(!remindersat.length){ + alert('Please define at least one hour for the reminder!'); + return; + } + + remindersat.sort(function(a,b){return a-b}); + past.sort(function(a,b){return b-a}); + + var highest = past[0] ? parseInt(past[0], 10) : 0; + + check(); + + function check(){ + timeleft = (lastday.getTime()-new Date().getTime())/3600000; + + if(highest && timeleft > highest){ + window.dashboardplus.setCookie('reminder', 1, -1); + } + + var val; + + for(var i in remindersat){ + val = parseFloat(remindersat[i]); + if(timeleft < val){ + addbanner(val); + } + } + } + + function addbanner(id){ + if(banner || $.inArray(''+id, past) != -1){ + if($.inArray(''+id, past) == -1){ + past.push(id); + window.dashboardplus.setCookie('reminder', past.join('|'), Math.ceil(timeleft/24)); + } + return; + } + + banner = $('').hide().prependTo('body').slideDown(); + $('body').animate({'padding-top':40}); + + banner.delegate('a.dbp-closebanner' ,'click', function(){ + past.push($(this).data('id')); + window.dashboardplus.setCookie('reminder', past.join('|'), Math.ceil(timeleft/24)); + banner.slideUp(); + $('body').animate({'padding-top':0}); + if(!$(this).attr('href')) return false; + }); + var timeelement = banner.find('strong'); + setInterval(function(){ + timeleft = (lastday.getTime()-new Date().getTime())/3600000; + timeelement.html(totime(timeleft)); + }, 1000); + } + + function totime(timeleft){ + sec_numb = Math.max(0, parseInt(timeleft * 3600, 10)); + var days = Math.floor(sec_numb / 86400); + var hours = Math.floor(sec_numb / 3600 - days * 24); + var minutes = Math.floor((sec_numb - (Math.floor(sec_numb / 3600) * 3600)) / 60); + var seconds = sec_numb - (Math.floor(sec_numb / 3600) * 3600) - (minutes * 60); + + if (hours < 10) {hours = "0"+hours;} + if (minutes < 10) {minutes = "0"+minutes;} + if (seconds < 10) {seconds = "0"+seconds;} + var time = (days ? days+(days == 1 ? ' day ' : ' days ') : '')+hours+':'+minutes+':'+seconds; + return time; + } + +})(); \ No newline at end of file diff --git a/dashboard-plus-chrome-plugin/plugins/replypantry.js b/dashboard-plus-chrome-plugin/plugins/replypantry.js new file mode 100644 index 0000000..13ca0d9 --- /dev/null +++ b/dashboard-plus-chrome-plugin/plugins/replypantry.js @@ -0,0 +1,381 @@ + +/*********************************************************************** + + ReplyPantry - Text in a Can + Canned reply text for Envato comments and forums + + By Chris Mavricos - SevenSpark + chris@sevenspark.com + http://sevenspark.com + + 2011-12-20 + v1.0 + +*************************************************************************/ + + +(function () { + + // Store item in local storage: + function setItem(key, value) { + try { + log("Storing [" + key + ":" + value + "]"); + window.localStorage.removeItem(key); // <-- Local storage! + window.localStorage.setItem(key, value); // <-- Local storage! + } catch(e) { + log("Error inside setItem"); + log(e); + } + log("Return from setItem" + key + ":" + value); + } + + // Gets item from local storage with specified key. + function getItem(key) { + var value; + log('Retrieving key [' + key + ']'); + try { + value = window.localStorage.getItem(key); // <-- Local storage! + }catch(e) { + log("Error inside getItem() for key:" + key); + log(e); + value = "null"; + } + log("Returning value: " + value); + return value; + } + + // Clears all key/value pairs in local storage. + function clearStrg() { + log('about to clear local storage'); + window.localStorage.clear(); // <-- Local storage! + log('cleared'); + } + + function log(txt) { + if(logging) { + console.log(txt); + } + } + + + function canEntry(key, val, cat){ + return $('
  • '+ + ''+key+' '+ + ''+val+' '+ + '× '+ + 'edit '+ + '
  • '); + } + + function saveCans(){ + localStorage.setItem('cans', JSON.stringify(cans)); + } + + + // Load up saved Cans - Retrieve the object from storage + var canObject = localStorage.getItem('cans'); + + var cans; + + var canKey = ''; + + var typeCat = ''; + + //Load default cans if none exist + if(canObject === null || canObject === '{}' || canObject == '' ){ + cans = { + 'Missing Stylesheet / Broken Theme' : { + 'text' : 'Hi! You need to unzip the file you downloaded and upload the theme inside it. Please see Solving broken theme issues', + 'cat' : 'forum' + }, + 'Contact the Author' : { + 'text' : 'Hi! This is a general ThemeForest forum. For product-specific support, please contact the author of that theme through their profile page. You can find the profile page by clicking the author avatar '+ + 'on the product page.', + 'cat' : 'forum' + }, + 'Support Forums' : { + 'text' : 'Hi, thanks for purchasing my product! All support is given through my Support Forum. Please create a support request there, and I\'ll get back to you as soon as possible. Thanks!', + 'cat' : 'comments' + } + }; + } + //Parse the cans into a JSON object + else cans = JSON.parse(canObject); + + //Grab the existing reply box + + //Forums + //var $replyBox = $('#items textarea[name="content"]'); //old + var $replyBox = $('#post_reply textarea[name="content"]'); + + //In the comments + if($replyBox.size() == 0){ + + var $commentReply = $('a.fancy-comment'); + if($commentReply.size() > 0){ + + $commentReply.click(function(){ + + setTimeout( function(){ + findReplyText(); + },500); + + }); + } + } + //In the forums + else{ + typeCat = 'forum'; + construct(); + } + //console.log('replyBoxCount: ' + $replyBox.size() ); + + function findReplyText(){ + + $replyBox = $('#reply_text'); + + //Box has loaded + if($replyBox.size() > 0){ + typeCat = 'comments'; + construct(); + } + else{ + setTimeout( function(){ + findReplyText(); + },500); + } + } + + function construct(){ + + //Setup Main Can Button + var $canbutton = $(''); + + /*$canbutton.click(function(e){ + e.preventDefault(); + $('#canpanel').fadeToggle('normal', function(){ + $('html').click(function(){ + $('#canpanel').fadeOut(); + }); + }); + });*/ + + $canbutton.on('click', function(e){ + + e.preventDefault(); + + //Close it + if( $canbutton.hasClass('can-lid-open') ){ + $canbutton.removeClass('can-lid-open'); + $('#canpanel').fadeOut(); + $('html').off('click.canclose'); + } + //Open it + else{ + $canbutton.addClass('can-lid-open'); + $('#canpanel').fadeIn(); + + $('html').on('click.canclose', function(e){ + + //Don't close if the can container was clicked. + if( $(e.target).parents('#cancontainer').size() > 0 ){ + return; + } + + $canbutton.removeClass('can-lid-open'); + $('#canpanel').fadeOut(); + $('html').off('click.canclose'); + }); + } + + return false; + }); + + //Build the can dialog + var $cancontainer = $('
    '); + var $canpanel = $('
    '); + var $cancontents = $('
    '); + $cancontents.append($('
    ')); + + //Build the list of cans + var $canlist = $('
      '); + + $.each(cans, function(key, data){ + $canlist.append(canEntry(key, data.text, data.cat)); + }); + + $cancontents.append($canlist); + $cancontainer.append($canpanel); + $cancontainer.append($canbutton); + + if(typeCat == 'comments'){ + $cancontainer.addClass('item-comments').insertBefore($replyBox); + } + else $cancontainer.insertAfter($replyBox); + + //Build the Editor + var $canEditor = $('
      '+ + '
      '+ + '× '+ + ' '+ + ''+ + ' '+ + '
      '+ + '
      '); + + //Build the Preview Box + //var $previewBox = $('
      '); + + + //Build List Buttons + var $canbuttons = $('
      '); + + //New Can Button + var $canNewButton = $('New Can'); + $canNewButton.click(function(e){ + e.preventDefault(); + + $canEditor.find('#cankey-editor-key').val(''); + $canEditor.find('#cankey-editor-val').val('New can text.'); + $canEditor.find('#cankey-editor-cat').val(''); + $canEditor.show('normal'); + + return false; + }); + $canbuttons.append($canNewButton); + + //Show All Button + var $canAllButton = $('All'); + $canAllButton.click(function(e){ + e.preventDefault(); + $cancontents.find('li').slideDown(); + }); + $canbuttons.append($canAllButton); + + //Forum Only Buttons + var $canForumButton = $('Forum'); + $canForumButton.click(function(e){ + e.preventDefault(); + $cancontents.find('li').slideUp(); + $cancontents.find('li[data-cat="forum"]').stop().slideDown(); + }); + $canbuttons.append($canForumButton); + + //Comment Only Button + var $canCommentButton = $('Comments'); + $canCommentButton.click(function(e){ + e.preventDefault(); + $cancontents.find('li').slideUp(); + $cancontents.find('li[data-cat="comments"]').stop().slideDown(); + }); + $canbuttons.append($canCommentButton); + + //Add Buttons + $canpanel.append($canbuttons); + $canpanel.append($cancontents); + $canpanel.append($canEditor); + //$canpanel.append($previewBox); + + //Insert Text Function + /*$('.cankey-op').live( 'click', function(e){ + console.log('click cankey op'); + e.preventDefault(); + var key = $(this).attr('data-key'); + $replyBox.val( $replyBox.val() + cans[key]['text'] ); + return false; + + });*/ + $(document).delegate('.cankey-op', 'click', function(e){ + e.preventDefault(); + var key = $(this).attr('data-key'); + $replyBox.val( $replyBox.val() + cans[key]['text'] ); + return false; + }); + + /*$(document).delegate('.cankey-op', 'hover', function(e){ + if( e.type === 'mouseenter' ) { + var content = $(this).find('span.cantext').html(); + $previewBox.stop().fadeIn().find('textarea').val(content); + } + else{ + $previewBox.fadeOut(); + } + });*/ + + + //Close Editor Function + $('#can-close-editor').click(function(e){ + + e.preventDefault(); + $canEditor.hide('normal'); + + return false; + }); + + //Edit Can Function + $('body').delegate('.cankey-edit','click', function(e){ + + e.preventDefault(); + canKey = $(this).attr('data-key'); + $canEditor.find('#cankey-editor-key').val(canKey); + $canEditor.find('#cankey-editor-val').val(cans[canKey]['text']); + $canEditor.find('#cankey-editor-cat').val(cans[canKey]['cat']); + $canEditor.show('normal'); + + return false; + + }).delegate('.cankey-remove', 'click', function(e){ + e.preventDefault(); + var key = $(this).parent().attr('data-key'); + + var answer = confirm("Really delete can '"+key+"'?") + if (answer){ + delete cans[key]; + $(this).parent().remove(); + saveCans(); + } + + return false; + + }); + + //Save Can Function + $('#cankey-editor-save').click(function(e){ + e.preventDefault(); + var key = $('#cankey-editor-key').val(); + var val = $('#cankey-editor-val').val(); + var cat = $('#cankey-editor-cat').val(); + + if(!key || key == ''){ + alert('You must enter a name for your can'); + return false; + } + + if(!val || val == ''){ + alert('Please enter some text to save'); + return false; + } + + //If new, add it + if( !(key in cans) ){ + $canlist.append( canEntry(key, val, cat ) ); + } + + cans[key] = { + 'text' : val, + 'cat' : cat + }; + saveCans(); + $canEditor.toggle('normal'); + + return false; + }); + } + + //Load styles + $('head').append(''); + +})(); diff --git a/dashboard-plus-chrome-plugin/plugins/salesrefresher.js b/dashboard-plus-chrome-plugin/plugins/salesrefresher.js new file mode 100644 index 0000000..67c7a6e --- /dev/null +++ b/dashboard-plus-chrome-plugin/plugins/salesrefresher.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2014 + * ================================== + * powered by revaxarts.com (http://revaxarts.com) + * original filename: salesrefresher.js + * filesize: 905 Bytes + * last modified: Sun, 26 Jan 2014 02:00:17 +0100 + * + */ +(function () { + + var useraccountnav = $('.header-logo-account__user-nav-item'); + // var user_balance = $('.header-logo-account__balance').attr('title', 'Click to reload'); + var user_balance = $('.global-header-menu__link-text').attr('title', 'Click to reload'); + + user_balance.on('click', function(){ + update(); + event.preventDefault(); + return false; + }); + + if(window.dashboardplus.get('salesrefresher', 'autoreload')){ + setInterval(function(){ + update(); + }, 300000); + } + + function update(){ + var old = user_balance.html(); + var count = old.length; + var temp = '$'; + var li = useraccountnav.find('li').eq(0); + + for(count; count > 4; count--){ + temp += '–'; + } + temp += '.––'; + li.css({width:li.width()}); + user_balance.html(temp); + + $.get(location.href, function(data){ + li.css({width:'auto'}); + var balance = data.match(/
      '); + return false; + } + + var url = 'https://marketplace.envato.com/api/edge/'+username+'/'+apikey+'/verify-purchase:'+code+'.json'; + + $.get(url, function(response){ + + var html = ''; + + if(response['verify-purchase'].created_at){ + var p = response['verify-purchase']; + var d = new Date(p.created_at); + html += ''+p.buyer+' purchased a '+p.licence+' of '+p.item_name+'on '+d.toLocaleString()+''; + $('#dpb_verify_purchase_result').html(html); + + }else{ + $('#dpb_verify_purchase_result').html('invalid purchasecode!'); + } + + }, "JSON"); + } + + +})(); \ No newline at end of file diff --git a/dashboard-plus-chrome-plugin/screenshot.png b/dashboard-plus-chrome-plugin/screenshot.png new file mode 100644 index 0000000..3573a19 Binary files /dev/null and b/dashboard-plus-chrome-plugin/screenshot.png differ diff --git a/dashboard-plus-chrome-plugin/script.js b/dashboard-plus-chrome-plugin/script.js new file mode 100644 index 0000000..dbc7435 --- /dev/null +++ b/dashboard-plus-chrome-plugin/script.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2014 + * ================================== + * powered by revaxarts.com (http://revaxarts.com) + * original filename: dashboardplus.user.js + * filesize: 951 Bytes + * last modified: Thu, 12 Jun 2014 07:46:24 +0200 + * + */ +// ==UserScript== +// @name Dashboard Plus for Envato Marketplaces +// @creator userscripts@revaxarts.com +// @namespace revaxarts.com +// @description Dashboard Plus for the Marketplaces. +// @date 2015-09-04 +// @version 1.4.9 +// @include http://activeden.net* +// @include http://audiojungle.net* +// @include http://themeforest.net* +// @include http://videohive.net* +// @include http://graphicriver.net* +// @include http://3docean.net* +// @include http://codecanyon.net* +// @include http://photodune.net* +// @include https://activeden.net* +// @include https://audiojungle.net* +// @include https://themeforest.net* +// @include https://videohive.net* +// @include https://graphicriver.net* +// @include https://3docean.net* +// @include https://codecanyon.net* +// @include https://photodune.net* +// ==/UserScript== + + + +// Define the base URI +var dashboardplus_base_uri = './bootstrap.js'; + +// Function to inject a script +function injectScript(srcUrl) { + var script = document.createElement('script'); + script.src = srcUrl; + (document.head || document.documentElement).appendChild(script); +} + +// Inject the inject.js script +injectScript(chrome.runtime.getURL('inject.js')); + +// Inject the bootstrap.js script from the dashboardplus base URI +injectScript(chrome.runtime.getURL('bootstrap.js')); \ No newline at end of file