From 6c6cf586df23d75485f957295aba3ee04fa6e76d Mon Sep 17 00:00:00 2001 From: Thomas Patrick Levy Date: Thu, 11 Feb 2016 14:23:39 -0800 Subject: [PATCH] v2.0.2 --- .jscsrc | 35 - .jshintrc | 87 - .travis.yml | 16 - _private/js/app/llms-ajax.js | 116 -- .../js/app/llms-metabox-course-outline.js | 814 -------- _private/js/app/llms-quiz.js | 294 --- _private/js/app/llms-review.js | 82 - _private/js/app/llms-tabs.js | 38 - _private/js/app/rest.js | 68 - _private/js/llms-ajax.js | 294 --- _private/js/llms-analytics.js | 296 --- _private/js/llms-form-checkout.js | 77 - _private/js/llms-lesson-locked.js | 20 - _private/js/llms-metabox-achievement.js | 62 - _private/js/llms-metabox-certificate.js | 62 - _private/js/llms-metabox-data.js | 76 - _private/js/llms-metabox-engagement.js | 149 -- _private/js/llms-metabox-fields.js | 44 - _private/js/llms-metabox-membership.js | 11 - _private/js/llms-metabox-quiz-builder.js | 184 -- _private/js/llms-metabox-single-question.js | 101 - _private/js/llms-metabox-students.js | 66 - _private/js/llms-metabox-syllabus.js | 558 ------ _private/js/llms-metabox-voucher.js | 158 -- _private/js/llms-metabox.js | 61 - _private/js/llms.js | 41 - _private/scss/_includes/_extends.scss | 26 - _private/scss/_includes/_mixins.scss | 59 - _private/scss/_includes/_vars.scss | 15 - .../scss/_includes/vendor/_font-awesome.scss | 1672 ----------------- _private/scss/admin.scss | 66 - _private/scss/admin/_fonts.scss | 14 - _private/scss/admin/_main.scss | 408 ---- _private/scss/admin/_tabs.scss | 46 - _private/scss/admin/breakpoints/2x.scss | 0 _private/scss/admin/breakpoints/_1030up.scss | 78 - _private/scss/admin/breakpoints/_1240up.scss | 10 - _private/scss/admin/breakpoints/_481up.scss | 15 - _private/scss/admin/breakpoints/_768up.scss | 67 - _private/scss/admin/breakpoints/_base.scss | 67 - .../scss/admin/modules/_course-outline.scss | 353 ---- _private/scss/admin/modules/_forms.scss | 232 --- _private/scss/admin/modules/_icons.scss | 92 - _private/scss/admin/modules/_mb-tabs.scss | 142 -- _private/scss/admin/modules/_top-modal.scss | 201 -- _private/scss/admin/modules/_voucher.scss | 118 -- _private/scss/admin/modules/_widgets.scss | 79 - _private/scss/admin/partials/_grid.scss | 277 --- _private/scss/admin/partials/_variables.scss | 14 - _private/scss/frontend/_llms-pagination.scss | 29 - _private/scss/frontend/_main.scss | 1106 ----------- _private/scss/frontend/_tooltip.scss | 46 - _private/scss/frontend/_voucher.scss | 3 - _private/scss/frontend/quiz-accordion.scss | 399 ---- _private/scss/frontend/quiz-timer.scss | 93 - _private/scss/lifterlms.scss | 19 - _private/svg/llms-icon-calendar.svg | 40 - _private/svg/llms-icon-checkmark.svg | 11 - _private/svg/llms-icon-circle-empty.svg | 10 - _private/svg/llms-icon-circle.svg | 7 - _private/svg/llms-icon-close.svg | 11 - _private/svg/llms-icon-course-section.svg | 23 - _private/svg/llms-icon-existing-lesson.svg | 16 - _private/svg/llms-icon-facebook.svg | 12 - _private/svg/llms-icon-folder.svg | 16 - _private/svg/llms-icon-free.svg | 6 - _private/svg/llms-icon-gear.svg | 17 - _private/svg/llms-icon-google.svg | 21 - _private/svg/llms-icon-graph.svg | 31 - _private/svg/llms-icon-instagram.svg | 22 - _private/svg/llms-icon-lightbulb.svg | 16 - _private/svg/llms-icon-linkedin.svg | 14 - _private/svg/llms-icon-lock.svg | 15 - _private/svg/llms-icon-media.svg | 17 - _private/svg/llms-icon-member.svg | 11 - _private/svg/llms-icon-new-lesson.svg | 9 - _private/svg/llms-icon-paper.svg | 16 - _private/svg/llms-icon-papers.svg | 29 - _private/svg/llms-icon-play.svg | 17 - _private/svg/llms-icon-plus.svg | 12 - _private/svg/llms-icon-question.svg | 18 - _private/svg/llms-icon-rightarrow.svg | 9 - _private/svg/llms-icon-search.svg | 13 - _private/svg/llms-icon-target.svg | 19 - _private/svg/llms-icon-twitter.svg | 16 - _private/svg/llms-icon-users.svg | 18 - _private/svg/llms-icon-view.svg | 18 - _private/svg/llms-icon-youtube.svg | 38 - _readme/description.md | 71 - _readme/faqs.md | 44 - _readme/header.md | 11 - _readme/installation.md | 12 - _readme/readme.txt | 11 - _readme/screenshots.md | 3 - bin/install-wp-tests.sh | 78 - composer.phar | Bin 1114511 -> 0 bytes gulpfile.js | 178 -- package.json | 41 - phpunit.xml | 14 - tests/bootstrap.php | 14 - tests/test-quiz.php | 83 - tests/test-sample.php | 17 - 102 files changed, 10681 deletions(-) delete mode 100644 .jscsrc delete mode 100644 .jshintrc delete mode 100644 .travis.yml delete mode 100644 _private/js/app/llms-ajax.js delete mode 100644 _private/js/app/llms-metabox-course-outline.js delete mode 100644 _private/js/app/llms-quiz.js delete mode 100644 _private/js/app/llms-review.js delete mode 100644 _private/js/app/llms-tabs.js delete mode 100644 _private/js/app/rest.js delete mode 100644 _private/js/llms-ajax.js delete mode 100644 _private/js/llms-analytics.js delete mode 100644 _private/js/llms-form-checkout.js delete mode 100644 _private/js/llms-lesson-locked.js delete mode 100644 _private/js/llms-metabox-achievement.js delete mode 100644 _private/js/llms-metabox-certificate.js delete mode 100644 _private/js/llms-metabox-data.js delete mode 100644 _private/js/llms-metabox-engagement.js delete mode 100644 _private/js/llms-metabox-fields.js delete mode 100644 _private/js/llms-metabox-membership.js delete mode 100644 _private/js/llms-metabox-quiz-builder.js delete mode 100644 _private/js/llms-metabox-single-question.js delete mode 100644 _private/js/llms-metabox-students.js delete mode 100644 _private/js/llms-metabox-syllabus.js delete mode 100644 _private/js/llms-metabox-voucher.js delete mode 100644 _private/js/llms-metabox.js delete mode 100644 _private/js/llms.js delete mode 100644 _private/scss/_includes/_extends.scss delete mode 100644 _private/scss/_includes/_mixins.scss delete mode 100644 _private/scss/_includes/_vars.scss delete mode 100644 _private/scss/_includes/vendor/_font-awesome.scss delete mode 100644 _private/scss/admin.scss delete mode 100644 _private/scss/admin/_fonts.scss delete mode 100644 _private/scss/admin/_main.scss delete mode 100644 _private/scss/admin/_tabs.scss delete mode 100644 _private/scss/admin/breakpoints/2x.scss delete mode 100644 _private/scss/admin/breakpoints/_1030up.scss delete mode 100644 _private/scss/admin/breakpoints/_1240up.scss delete mode 100644 _private/scss/admin/breakpoints/_481up.scss delete mode 100644 _private/scss/admin/breakpoints/_768up.scss delete mode 100644 _private/scss/admin/breakpoints/_base.scss delete mode 100644 _private/scss/admin/modules/_course-outline.scss delete mode 100644 _private/scss/admin/modules/_forms.scss delete mode 100644 _private/scss/admin/modules/_icons.scss delete mode 100644 _private/scss/admin/modules/_mb-tabs.scss delete mode 100644 _private/scss/admin/modules/_top-modal.scss delete mode 100644 _private/scss/admin/modules/_voucher.scss delete mode 100644 _private/scss/admin/modules/_widgets.scss delete mode 100644 _private/scss/admin/partials/_grid.scss delete mode 100644 _private/scss/admin/partials/_variables.scss delete mode 100644 _private/scss/frontend/_llms-pagination.scss delete mode 100644 _private/scss/frontend/_main.scss delete mode 100644 _private/scss/frontend/_tooltip.scss delete mode 100644 _private/scss/frontend/_voucher.scss delete mode 100644 _private/scss/frontend/quiz-accordion.scss delete mode 100644 _private/scss/frontend/quiz-timer.scss delete mode 100644 _private/scss/lifterlms.scss delete mode 100644 _private/svg/llms-icon-calendar.svg delete mode 100644 _private/svg/llms-icon-checkmark.svg delete mode 100644 _private/svg/llms-icon-circle-empty.svg delete mode 100644 _private/svg/llms-icon-circle.svg delete mode 100644 _private/svg/llms-icon-close.svg delete mode 100644 _private/svg/llms-icon-course-section.svg delete mode 100644 _private/svg/llms-icon-existing-lesson.svg delete mode 100644 _private/svg/llms-icon-facebook.svg delete mode 100644 _private/svg/llms-icon-folder.svg delete mode 100644 _private/svg/llms-icon-free.svg delete mode 100644 _private/svg/llms-icon-gear.svg delete mode 100644 _private/svg/llms-icon-google.svg delete mode 100644 _private/svg/llms-icon-graph.svg delete mode 100644 _private/svg/llms-icon-instagram.svg delete mode 100644 _private/svg/llms-icon-lightbulb.svg delete mode 100644 _private/svg/llms-icon-linkedin.svg delete mode 100644 _private/svg/llms-icon-lock.svg delete mode 100644 _private/svg/llms-icon-media.svg delete mode 100644 _private/svg/llms-icon-member.svg delete mode 100644 _private/svg/llms-icon-new-lesson.svg delete mode 100644 _private/svg/llms-icon-paper.svg delete mode 100644 _private/svg/llms-icon-papers.svg delete mode 100644 _private/svg/llms-icon-play.svg delete mode 100644 _private/svg/llms-icon-plus.svg delete mode 100644 _private/svg/llms-icon-question.svg delete mode 100644 _private/svg/llms-icon-rightarrow.svg delete mode 100644 _private/svg/llms-icon-search.svg delete mode 100644 _private/svg/llms-icon-target.svg delete mode 100644 _private/svg/llms-icon-twitter.svg delete mode 100644 _private/svg/llms-icon-users.svg delete mode 100644 _private/svg/llms-icon-view.svg delete mode 100644 _private/svg/llms-icon-youtube.svg delete mode 100644 _readme/description.md delete mode 100644 _readme/faqs.md delete mode 100644 _readme/header.md delete mode 100644 _readme/installation.md delete mode 100644 _readme/readme.txt delete mode 100644 _readme/screenshots.md delete mode 100755 bin/install-wp-tests.sh delete mode 100755 composer.phar delete mode 100644 gulpfile.js delete mode 100644 package.json delete mode 100644 phpunit.xml delete mode 100644 tests/bootstrap.php delete mode 100644 tests/test-quiz.php delete mode 100644 tests/test-sample.php diff --git a/.jscsrc b/.jscsrc deleted file mode 100644 index 2a2cf34504..0000000000 --- a/.jscsrc +++ /dev/null @@ -1,35 +0,0 @@ -{ - "requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch", "case", "default"], - // "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"], - "requireParenthesesAroundIIFE": true, - // "requireSpacesInFunctionExpression": { "beforeOpeningCurlyBrace": true }, - // "disallowSpacesInFunctionExpression": { "beforeOpeningRoundBrace": true }, - "requireMultipleVarDecl": true, - "disallowEmptyBlocks": true, - // "disallowSpacesInsideObjectBrackets": true, - // "disallowSpacesInsideArrayBrackets": true, - // "disallowSpacesInsideParentheses": true, - "disallowQuotedKeysInObjects": "allButReserved", - "requireCommaBeforeLineBreak": true, - "requireOperatorBeforeLineBreak": ["?", "+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="], - // "disallowLeftStickedOperators": ["?", "+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="], - // "requireRightStickedOperators": ["!"], - // "disallowRightStickedOperators": ["?", "+", "/", "*", ":", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="], - //"requireLeftStickedOperators": [","], - "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], - "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], - "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], - "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], - "disallowKeywords": ["with"], - "disallowMultipleLineBreaks": true, - "validateLineBreaks": "LF", - "validateQuoteMarks": "'", - // "disallowMixedSpacesAndTabs": true, - // "disallowTrailingWhitespace": false, - "disallowKeywordsOnNewLine": ["else"], - "requireLineFeedAtFileEnd": true, - "maximumLineLength": 120, - // "requireCapitalizedConstructors": true, - "requireDotNotation": true, - "excludeFiles": ["node_modules/**"] -} \ No newline at end of file diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 13b2057b4d..0000000000 --- a/.jshintrc +++ /dev/null @@ -1,87 +0,0 @@ -{ - // JSHint Default Configuration File (as on JSHint website) - // See http://jshint.com/docs/ for more details - - "maxerr" : 50, // {int} Maximum error before stopping - - // Enforcing - "bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.) - "camelcase" : false, // true: Identifiers must be in camelCase - "curly" : true, // true: Require {} for every new block or scope - "eqeqeq" : true, // true: Require triple equals (===) for comparison - "forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty() - "freeze" : true, // true: prohibits overwriting prototypes of native objects such as Array, Date etc. - "immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());` - "indent" : 4, // {int} Number of spaces to use for indentation - "latedef" : false, // true: Require variables/functions to be defined before being used - "newcap" : false, // true: Require capitalization of all constructor functions e.g. `new F()` - "noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee` - "noempty" : true, // true: Prohibit use of empty blocks - "nonbsp" : false, // true: Prohibit "non-breaking whitespace" characters. - "nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment) - "plusplus" : false, // true: Prohibit use of `++` & `--` - "quotmark" : false, // Quotation mark consistency: - // false : do nothing (default) - // true : ensure whatever is used is consistent - // "single" : require single quotes - // "double" : require double quotes - "undef" : true, // true: Require all non-global variables to be declared (prevents global leaks) - "unused" : true, // true: Require all defined variables be used - "strict" : true, // true: Requires all functions run in ES5 Strict Mode - "maxparams" : false, // {int} Max number of formal params allowed per function - "maxdepth" : false, // {int} Max depth of nested blocks (within functions) - "maxstatements" : false, // {int} Max number statements per function - "maxcomplexity" : false, // {int} Max cyclomatic complexity per function - "maxlen" : false, // {int} Max number of characters per line - - // Relaxing - "asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons) - "boss" : false, // true: Tolerate assignments where comparisons would be expected - "debug" : false, // true: Allow debugger statements e.g. browser breakpoints. - "eqnull" : false, // true: Tolerate use of `== null` - "es5" : false, // true: Allow ES5 syntax (ex: getters and setters) - "esnext" : false, // true: Allow ES.next (ES6) syntax (ex: `const`) - "moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features) - // (ex: `for each`, multiple try/catch, function expression…) - "evil" : false, // true: Tolerate use of `eval` and `new Function()` - "expr" : false, // true: Tolerate `ExpressionStatement` as Programs - "funcscope" : false, // true: Tolerate defining variables inside control statements - "globalstrict" : false, // true: Allow global "use strict" (also enables 'strict') - "iterator" : false, // true: Tolerate using the `__iterator__` property - "lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block - "laxbreak" : false, // true: Tolerate possibly unsafe line breakings - "laxcomma" : false, // true: Tolerate comma-first style coding - "loopfunc" : false, // true: Tolerate functions being defined in loops - "multistr" : false, // true: Tolerate multi-line strings - "noyield" : false, // true: Tolerate generator functions with no yield statement in them. - "notypeof" : false, // true: Tolerate invalid typeof operator values - "proto" : false, // true: Tolerate using the `__proto__` property - "scripturl" : false, // true: Tolerate script-targeted URLs - "shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;` - "sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation - "supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;` - "validthis" : false, // true: Tolerate using this in a non-constructor function - - // Environments - "browser" : true, // Web Browser (window, document, etc) - "browserify" : false, // Browserify (node.js code in the browser) - "couch" : false, // CouchDB - "devel" : true, // Development/debugging (alert, confirm, etc) - "dojo" : false, // Dojo Toolkit - "jasmine" : false, // Jasmine - "jquery" : false, // jQuery - "mocha" : true, // Mocha - "mootools" : false, // MooTools - "node" : false, // Node.js - "nonstandard" : false, // Widely adopted globals (escape, unescape, etc) - "prototypejs" : false, // Prototype and Scriptaculous - "qunit" : false, // QUnit - "rhino" : false, // Rhino - "shelljs" : false, // ShellJS - "worker" : false, // Web Workers - "wsh" : false, // Windows Scripting Host - "yui" : false, // Yahoo User Interface - - // Custom Globals - "globals" : {} // additional predefined global variables -} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 64be0af086..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -language: php - -php: - - 5.3 - - 5.4 - -env: - - WP_VERSION=latest WP_MULTISITE=0 - - WP_VERSION=latest WP_MULTISITE=1 - - WP_VERSION=3.8 WP_MULTISITE=0 - - WP_VERSION=3.8 WP_MULTISITE=1 - -before_script: - - bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION - -script: phpunit diff --git a/_private/js/app/llms-ajax.js b/_private/js/app/llms-ajax.js deleted file mode 100644 index 7fcdd0b227..0000000000 --- a/_private/js/app/llms-ajax.js +++ /dev/null @@ -1,116 +0,0 @@ -/* global LLMS, $, wp_ajax_data */ -/* jshint strict: false */ - -/** - * Main Ajax class - * Handles Primary Ajax connection - * @type {Object} - */ -LLMS.Ajax = { - - /** - * url - * @type {String} - */ - url: window.ajaxurl || window.llms.ajaxurl, - - /** - * type - * @type {[type]} - */ - type: 'post', - - /** - * data - * @type {[type]} - */ - data: [], - - /** - * cache - * @type {[type]} - */ - cache: false, - - /** - * dataType - * defaulted to json - * @type {String} - */ - dataType: 'json', - - /** - * async - * default to false - * @type {Boolean} - */ - async: true, - - response:[], - - /** - * initilize Ajax methods - * loads class methods - */ - init: function(obj) { - - //if obj is not of type object or null return false; - if( obj === null || typeof obj !== 'object' ) { - return false; - } - - //set object defaults if values are not supplied - obj.url = this.url; - obj.type = 'type' in obj ? obj.type : this.type; - obj.data = 'data' in obj ? obj.data : this.data; - obj.cache = 'cache' in obj ? obj.cache : this.cache; - obj.dataType = 'dataType' in obj ? obj.dataType : this.dataType; - obj.async = 'async' in obj ? obj.async : this.async; - - //add nonce to data object - obj.data._ajax_nonce = wp_ajax_data.nonce; - - //add post id to data object - var $R = LLMS.Rest, - query_vars = $R.get_query_vars(); - obj.data.post_id = 'post' in query_vars ? query_vars.post : null; - - return obj; - }, - - /** - * Call - * Called by external classes - * Sets up jQuery Ajax object - * @param {[object]} [object of ajax settings] - * @return {[mixed]} [false if not object or this] - */ - call: function(obj) { - - //get default variables if not included in call - var settings = this.init(obj); - - //if init return a response of false - if (!settings) { - return false; - } else { - this.request(settings); - } - - return this; - - }, - - /** - * Calls jQuery Ajax on settings object - * @return {[object]} [this] - */ - request: function(settings) { - - $.ajax(settings); - - return this; - - } - -}; diff --git a/_private/js/app/llms-metabox-course-outline.js b/_private/js/app/llms-metabox-course-outline.js deleted file mode 100644 index 4faf24c438..0000000000 --- a/_private/js/app/llms-metabox-course-outline.js +++ /dev/null @@ -1,814 +0,0 @@ -/* global LLMS, $ */ -/* jshint strict: false */ - -/** - * Front End Quiz Class - * Applies only to post type quiz - * @type {Object} - */ -LLMS.MB_Course_Outline = { - - /** - * init - * loads class methods - */ - init: function() { - - if ($('#llms_post_edit_type').length ) { - if ($('#llms_post_edit_type').val() === 'course') { - this.bind(); - } - } - - }, - alreadySubmitted: false, - /** - * Bind Method - * Handles dom binding on load - */ - bind: function() { - var _this = this; - - $(document).ready(function() { - //add section row js functionality - _this.addSectionRowFunctionality(); - - //add lesson row js functionality - _this.addLessonRowFunctionality(); - }); - - $('.llms-modal-cancel').click(function (e) { - e.preventDefault(); - $(window).trigger('build'); - }); - - $(document).ready(function () { - $('.llms-chosen-select').chosen({width: '100%'}); - }); - - //hack to resize excerpt and content editor size. - //There is a WP but where passing the css_options to wp_editor - //does not work. - $('.tab-link').on('click', function () { - $('#content_ifr').css('height', '300px'); - $('#excerpt_ifr').css('height', '300px'); - }); - - //show / hide prereq lesson select based on setting - if ($('#_has_prerequisite').attr('checked')) { - $('.llms-prereq-top').addClass('top'); - $('.llms-prereq-bottom').show(); - - } else { - $('.llms-prereq-bottom').hide(); - } - $('#_has_prerequisite').change(function () { - if ($('#_has_prerequisite').attr('checked')) { - $('.llms-prereq-top').addClass('top'); - $('.llms-prereq-bottom').show(); - - } else { - $('.llms-prereq-top').removeClass('top'); - $('.llms-prereq-bottom').hide(); - } - }); - - this.toggle_custom_single_price_field(); - - //generic modal call - $('a.llms-modal').click(function () { - $('#' + $(this).attr('data-modal_id')).topModal({ - title: $(this).attr('data-modal_title'), - closed: function () { - _this.alreadySubmitted = false; - } - }); - }); - - //add new lesson modal - $('a.llms-modal-new-lesson-link').click(function () { - $('#' + $(this).attr('data-modal_id')).topModal({ - title: $(this).attr('data-modal_title'), - open: function () { - _this.getSections(); - $('#llms_create_lesson').find('input[value="Create Lesson"]').removeProp('disabled'); - }, - closed: function () { - _this.alreadySubmitted = false; - } - }); - }); - - //add existing lesson modal - $('a.llms-modal-existing-lesson-link').click(function () { - $('#' + $(this).attr('data-modal_id')).topModal({ - title: $(this).attr('data-modal_title'), - open: function () { - _this.getSections(); - _this.getLessons(); - }, - closed: function () { - _this.alreadySubmitted = false; - } - }); - }); - - this.setup_course(); - - $(window).click(function (e) { - if (e.target.id !== 'llms-outline-add' && $('#llms-outline-add').hasClass('clicked')) { - $('#llms-outline-menu').css('display', 'none'); - reset(); - } - }); - - function reset() { - $('#llms-outline-add').removeClass('clicked'); - $('#llms-outline-add').addClass('bt'); - $('#llms-outline-menu').removeClass('fade-in'); - $('#triangle').show(); - } - - $(window).scroll(function () { - if ($('#llms-outline-add').hasClass('clicked')) { - $('#triangle').hide(); - var popover = $('#llms-outline-menu'), - top = -($('#llms-outline-add').offset().top) - 81 + - $(window).scrollTop() + ($(window).height() / 2); - popover.css('top', top); - } - }); - - $('#llms-outline-add').click(function (e) { - e.preventDefault(); - var popover = $('#llms-outline-menu'); - if ($(this).hasClass('bt')) { - if ($(this).offset().top - $(window).scrollTop() < 200) { - popover.css('top', '43px'); - if ($(window).width() < 851) { - popover.find('#triangle').css('left', '164px'); - popover.css('top', '57px'); - popover.css('left', '-138px'); - popover.css('bottom', '15px'); - } - } else { - popover.css('top', ''); - if ($(window).width() < 851) { - popover.css('top', '-54px'); - var left = $(window).width() < 400 ? -Math.abs($(window).width() / 2) : -242; - left += 'px'; - popover.css('left', left); - popover.css('bottom', '15px'); - popover.find('#triangle').css('left', '227px'); - } - } - $(this).removeClass('bt'); - $(this).addClass('clicked'); - popover.addClass('fade-in'); - popover.css('display', 'block'); - } else { - $(this).removeClass('clicked'); - $(this).addClass('bt'); - popover.removeClass('fade-in'); - popover.css('display', 'none'); - popover.find('#triangle').show(); - } - }); - - $('#tooltip_menu a').click(function (e) { - var popover = $('#llms-outline-menu'); - popover.removeClass('fade-in'); - popover.css('display', 'none'); - e.preventDefault(); - }); - - $('a.tooltip').click(function (e) { - e.preventDefault(); - }); - - //section form submit - $('#llms_create_section').on('submit', function (e) { - e.preventDefault(); - var values = {}; - $.each($(this).serializeArray(), function (i, field) { - values[field.name] = field.value; - }); - if (_this.alreadySubmitted === false) { - _this.alreadySubmitted = true; - _this.createSection(values); - } - }); - - //new lesson form submit - $('#llms_create_lesson').on('submit', function (e) { - e.preventDefault(); - var values = {}; - $.each($(this).serializeArray(), function (i, field) { - values[field.name] = field.value; - }); - if (_this.alreadySubmitted === false) { - _this.alreadySubmitted = true; - _this.createLesson(values); - } - - }); - - //add existing lesson form submit - $('#llms_add_existing_lesson').on('submit', function (e) { - e.preventDefault(); - - var values = {}; - $.each($(this).serializeArray(), function (i, field) { - values[field.name] = field.value; - }); - if (_this.alreadySubmitted === false) { - _this.alreadySubmitted = true; - _this.addExistingLesson(values); - } - - }); - - //update lesson title - $('#llms_edit_lesson').on('submit', function (e) { - e.preventDefault(); - - var values = {}; - $.each($(this).serializeArray(), function (i, field) { - values[field.name] = field.value; - }); - - _this.updateLesson(values); - - }); - - //update section title - $('#llms_edit_section').on('submit', function (e) { - e.preventDefault(); - - var values = {}; - $.each($(this).serializeArray(), function (i, field) { - values[field.name] = field.value; - }); - - _this.updateSection(values); - - }); - - //update lesson title - $('#llms_delete_section').on('submit', function (e) { - e.preventDefault(); - - var values = {}; - $.each($(this).serializeArray(), function (i, field) { - values[field.name] = field.value; - }); - - _this.deleteSection(values); - }); - }, - - toggle_custom_single_price_field: function() - { - //show / hide prereq lesson select based on setting - if ($('#_is_custom_single_price').attr('checked')) { - $('.llms-custom-single-price-top').removeClass('bottom'); - $('.llms-custom-single-price-top').addClass('top'); - $('.llms-custom-single-price-bottom').show(); - - } else { - $('.llms-custom-single-price-bottom').hide(); - } - $('#_is_custom_single_price').change(function () { - if ($('#_is_custom_single_price').attr('checked')) { - $('.llms-custom-single-price-top').removeClass('bottom'); - $('.llms-custom-single-price-top').addClass('top'); - $('.llms-custom-single-price-bottom').show(); - - } else { - $('.llms-custom-single-price-top').removeClass('top'); - $('.llms-custom-single-price-top').addClass('bottom'); - $('.llms-custom-single-price-bottom').hide(); - } - }); - }, - resortSections: function() { - - var section_tree = {}; - - $( '.llms-section' ).each( function(i) { - i++; - - //update the sections to display the new order - $(this).find('[name="llms_section_order[]"]').val(i); - $(this).find('.llms-section-order').html(i); - - var id = $(this).find('[name="llms_section_id[]"]').val(); - - //add section id and order to section tree object - section_tree[id] = i; - //update the new order in the database - - }); - - LLMS.MB_Course_Outline.updateSectionOrder( section_tree ); - - }, - - updateSectionOrder: function( section_tree ) { - console.log(section_tree); - LLMS.Ajax.call({ - data: { - action: 'update_section_order', - sections: section_tree - }, - beforeSend: function() { - }, - success: function(r) { - console.log(r); - } - }); - }, - - updateLessonOrder: function( lesson_tree ) { - console.log(lesson_tree); - LLMS.Ajax.call({ - data: { - action: 'update_lesson_order', - lessons: lesson_tree - }, - beforeSend: function() { - }, - success: function(r) { - console.log(r); - - } - }); - }, - - resortLessons: function() { - - var lesson_tree = {}; - - $( '.llms-lesson-tree' ).each( function() { - - //loop through all lessons and set order - $(this).find( '.llms-lesson').each( function(i) { - i++; - - //set parent section - var parentSection = $(this).parent().parent().find('[name="llms_section_id[]"]').val(); - // alert(parentSection); - $(this).find('[name="llms_lesson_parent_section[]"]').val(parentSection); - - //set the new order - $(this).find('[name="llms_lesson_order[]"]').val(i); - $(this).find('.llms-lesson-order').html(i); - console.log(parentSection); - - //save parent section and order to object - var id = $(this).find('[name="llms_lesson_id[]"]').val(); - lesson_tree[id] = { - parent_section : parentSection, - order : i - }; - - }); - }); - - LLMS.MB_Course_Outline.updateLessonOrder( lesson_tree ); - - }, - - createSection: function( values ) { - LLMS.Ajax.call({ - data: { - action: 'create_section', - title: values.llms_section_name - - }, - beforeSend: function() { - }, - success: function(r) { - console.log(r); - - if ( r.success === true ) { - - $('#llms_course_outline_sort').append(r.data); - $(window).trigger('build'); - LLMS.MB_Course_Outline.addSectionRowFunctionality(); - - //clear form - $( '#llms_create_section' ).each(function(){ - this.reset(); - }); - } - } - }); - }, - - addSectionRowFunctionality: function() { - - //lesson sortable functionality - $( '.llms-lesson-tree' ).sortable({ - connectWith: '.llms-lesson-tree', - axis : 'y', - placeholder : 'placeholder', - cursor : 'move', - forcePlaceholderSize:true, - stop: function() { - - LLMS.MB_Course_Outline.resortLessons(); - } - - }).disableSelection(); - - $( '#llms_course_outline_sort' ).sortable({ - connectWith: '.sortablewrapper', - axis : 'y', - placeholder : 'placeholder', - cursor : 'move', - forcePlaceholderSize:true, - stop: function() { - LLMS.MB_Course_Outline.resortSections(); - } - }).disableSelection(); - - //edit section modal - $('a.llms-edit-section-link').click(function(){ - var _that = $(this); - $('#' + $(this).attr('data-modal_id') ).topModal( { - title: $(this).attr('data-modal_title'), - open: function() { - var section_id = _that.parent().parent().find('[name="llms_section_id[]"]').val(); - LLMS.MB_Course_Outline.getSection(section_id); - } - }); - }); - - //delete section modal - $('a.llms-delete-section-link').click(function(){ - var _that = $(this); - $('#' + $(this).attr('data-modal_id') ).topModal( { - title: $(this).attr('data-modal_title'), - open: function() { - - var section_id = _that.parent().parent().find('[name="llms_section_id[]"]').val(); - $('#llms-section-delete-id').val(section_id); - } - }); - }); - }, - - addLessonRowFunctionality: function() { - - //edit lesson modal - $('a.llms-edit-lesson-link').click(function(){ - var _that = $(this); - $('#' + $(this).attr('data-modal_id') ).topModal( { - title: $(this).attr('data-modal_title'), - open: function() { - var lesson_id = _that.parent().parent().parent().find('[name="llms_lesson_id[]"]').val(); - LLMS.MB_Course_Outline.getLesson(lesson_id); - } - }); - }); - - //update lesson title - $( '.llms-remove-lesson-link' ).on( 'click', function(e) { - e.preventDefault(); - - var lesson_id = $(this).parent().parent().parent().find('[name="llms_lesson_id[]"]').val(); - - LLMS.MB_Course_Outline.removeLesson( lesson_id ); - }); - }, - - createLesson: function( values ) { - LLMS.Ajax.call({ - data: { - action: 'create_lesson', - title: values.llms_lesson_name, - excerpt: values.llms_lesson_excerpt, - section_id: values.llms_section - }, - beforeSend: function() { - }, - success: function(r) { - console.log(r); - - if ( r.success === true ) { - - //find the correct section and attach lesson - $( '.llms-section' ).each( function() { - - var input_value = $(this).find('[name="llms_section_id[]"]').val(); - console.log(input_value); - if ( input_value === values.llms_section ) { - console.log('found one'); - console.log($(this)); - console.log($(this).find('.llms_lesson_tree')); - $(this).find( '#llms_section_tree_' + values.llms_section ).append(r.data); - } - - }); - - //close modal window - $(window).trigger('build'); - LLMS.MB_Course_Outline.addLessonRowFunctionality(); - - //clear form - $( '#llms_create_lesson' ).each(function(){ - this.reset(); - }); - } - }, - }); - }, - - addExistingLesson: function( values ) { - - LLMS.Ajax.call({ - data: { - action: 'add_lesson_to_course', - lesson_id: values.llms_lesson, - section_id: values.llms_section - }, - beforeSend: function() { - }, - success: function(r) { - - if ( r.success === true ) { - - $( '.llms-section' ).each( function() { - - var input_value = $(this).find('[name="llms_section_id[]"]').val(); - console.log(input_value); - if ( input_value === values.llms_section ) { - $(this).find( '#llms_section_tree_' + values.llms_section ).append(r.data); - } - - }); - - //close modal window - $(window).trigger('build'); - LLMS.MB_Course_Outline.addLessonRowFunctionality(); - - $( '#llms_add_existing_lesson' ).each(function(){ - this.reset(); - }); - } - } - }); - }, - - getSections: function() { - - LLMS.Ajax.call({ - data: { - action: 'get_course_sections', - }, - success: function(r) { - - if ( r.success === true ) { - - $('#llms-section-select').empty(); - - $.each(r.data, function(key, value) { - //append a new option for each result - var newOption = $(''); - $('#llms-section-select').append(newOption); - }); - - // refresh option list - $('#llms-section-select').trigger('chosen:updated'); - } - } - }); - }, - - getSection: function( section_id ) { - console.log(section_id); - LLMS.Ajax.call({ - data: { - action: 'get_course_section', - section_id: section_id - }, - success: function(r) { - - if ( r.success === true ) { - - $('#llms-section-edit-name').val(r.data.post.post_title); - $('#llms-section-edit-id').val(r.data.id); - } - } - }); - }, - - getLesson: function( lesson_id ) { -console.log(lesson_id); - LLMS.Ajax.call({ - data: { - action: 'get_course_lesson', - lesson_id: lesson_id - }, - success: function(r) { - - if ( r.success === true ) { - - $('#llms-lesson-edit-name').val(r.data.post.post_title); - $('#llms-lesson-edit-excerpt').val(r.data.post.post_excerpt); - $('#llms-lesson-edit-id').val(r.data.id); - } - } - }); - }, - - updateSection: function( values ) { - - LLMS.Ajax.call({ - data: { - action: 'update_course_section', - section_id: values.llms_section_edit_id, - title: values.llms_section_edit_name - }, - success: function(r) { - - if ( r.success === true ) { - - //find and update section title in tree - //find the correct section and attach lesson - $( '.llms-section' ).each( function() { - - var input_value = $(this).find('[name="llms_section_id[]"]').val(); - console.log(input_value); - if ( input_value === values.llms_section_edit_id ) { - console.log('found one'); - console.log($(this)); - console.log($(this).find('.llms-section-title')); - $(this).find( '.llms-section-title' ).html(r.data.title); - } - - }); - - $(window).trigger('build'); - - //clear form - $( '#llms_edit_section' ).each(function(){ - this.reset(); - }); - } - } - }); - }, - - updateLesson: function( values ) { - - LLMS.Ajax.call({ - data: { - action: 'update_course_lesson', - lesson_id: values.llms_lesson_edit_id, - title: values.llms_lesson_edit_name, - excerpt: values.llms_lesson_edit_excerpt - }, - success: function(r) { - - if ( r.success === true ) { - - //find the correct lesson and update the title and description - $( '.llms-lesson' ).each( function() { - - var input_value = $(this).find('[name="llms_lesson_id[]"]').val(); - console.log(input_value); - if ( input_value === values.llms_lesson_edit_id ) { - $(this).find( '.llms-lesson-title' ).html(r.data.title.title); - $(this).find( '.llms-lesson-excerpt' ).html(r.data.excerpt.post_excerpt); - } - - }); - - $(window).trigger('build'); - - $( '#llms_edit_lesson' ).each(function(){ - this.reset(); - }); - } - } - }); - }, - - removeLesson: function( lesson_id ) { - - LLMS.Ajax.call({ - data: { - action: 'remove_course_lesson', - lesson_id: lesson_id, - }, - success: function(r) { - - if ( r.success === true ) { - - //find the correct lesson and remove it - $( '.llms-lesson' ).each( function() { - - var input_value = $(this).find('[name="llms_lesson_id[]"]').val(); - console.log(input_value); - if ( input_value === lesson_id ) { - $(this).remove(); - LLMS.MB_Course_Outline.resortLessons(); - } - - }); - } - } - }); - }, - - deleteSection: function( values ) { - - LLMS.Ajax.call({ - data: { - action: 'delete_course_section', - section_id: values.llms_section_delete_id, - }, - success: function(r) { - - if ( r.success === true ) { - - //find the correct lesson and remove it - $( '.llms-section' ).each( function() { - - var input_value = $(this).find('[name="llms_section_id[]"]').val(); - console.log(input_value); - if ( input_value === values.llms_section_delete_id ) { - $(this).remove(); - LLMS.MB_Course_Outline.resortSections(); - } - - }); - - $(window).trigger('build'); - } - } - }); - }, - - getLessons: function() { - - LLMS.Ajax.call({ - data: { - action: 'get_lesson_options_for_select', - }, - success: function(r) { - - if ( r.success === true ) { - $('#llms-lesson-select').empty(); - - $.each(r.data, function(key, value) { - //append a new option for each result - var newOption = $(''); - $('#llms-lesson-select').append(newOption); - - }); - - // refresh option list - $('#llms-lesson-select').trigger('chosen:updated'); - } - } - }); - }, - - /** - * Initial Course setup - * displays modal window - * User enters course name - * Submit adds title to course and saves course as draft. - * @return {[type]} [description] - */ - setup_course: function() { - - //only run this function on new posts of type course - var $R = LLMS.Rest, - new_post = ['post-new.php'], - post_type = 'course', - query_vars = $R.get_query_vars(); - - if ( $R.is_path(new_post) && query_vars.post_type === post_type ) { - $(document).ready(function() { - $('#pop1').topModal( { - title: 'Create New Course' - }); - }); - - //on submit set course title and save post as draft - $( '#llms-create-course-submit').click(function(e) { - - $('#title').val( $('#llms-course-name').val() ); - $('#save-post').click(); - ////save for later when you want to close a modal - // $('#TB_window').fadeOut(); - // self.parent.tb_remove(); - e.preventDefault(); - }); - } - } -}; diff --git a/_private/js/app/llms-quiz.js b/_private/js/app/llms-quiz.js deleted file mode 100644 index 2416ddf5d8..0000000000 --- a/_private/js/app/llms-quiz.js +++ /dev/null @@ -1,294 +0,0 @@ -/* global LLMS, Ajax, $ */ -/* jshint strict: false */ - -/** - * Front End Quiz Class - * Applies only to post type quiz - * @type {Object} - */ -LLMS.Quiz = { - - /** - * init - * loads class methods - */ - init: function() { - - var $R = LLMS.Rest, - post_type = ['llms_quiz']; - - if ( $R.is_path(post_type) ) { - this.bind(); - } - - }, - - /** - * Bind Method - * Handles dom binding on load - * @return {[type]} [description] - */ - bind: function() { - var that = this; - - //hides the quiz timer when page loads - $('#llms-quiz-timer').hide(); - - // calls start quiz on "Start Quiz" button click - $('#llms_start_quiz').click(function() { - that.start_quiz(); - return false; - }); - - $('.view-summary').click(function() { - var accordion = $('.accordion'); - if(accordion.hasClass('hidden')) { - accordion.fadeIn(300); - accordion.removeClass('hidden'); - $(this).text('Hide Summary'); - } else{ - accordion.fadeOut(300); - accordion.addClass('hidden'); - $(this).text('View Summary'); - } - }); - - //draw quiz grade circular chart - this.chart_quiz_grade(); - - }, - - /** - * Draws quiz grade circular charts - * @return {[void]} - */ - chart_quiz_grade: function() { - - /** - * Used for populating the quiz grade svg graph - * @type {[type]} - */ - var $llms_circ = $('.llms-animated-circle'), - $llms_prog_count = $('.llms-progress-circle-count'), - llms_grade_perc = $('#llms-grade-value').val(), - llms_circ_offset = 430 * llms_grade_perc / 100; - - $llms_circ.css({ - 'stroke-dashoffset' : 430 - llms_circ_offset - }); - - $llms_prog_count.html(Math.round(llms_grade_perc) + '%'); - - }, - - /** - * Start Quiz - * Finds values of quiz-id and user-id - * Calls ajax.start_quiz - * @return {[void]} - */ - start_quiz: function () { - - var post_id = $('#llms-quiz').val(), - user_id = $('#llms-user').val(), - ajax = new Ajax( 'post', { - action : 'start_quiz', - quiz_id : post_id, - user_id : user_id - }, true); - - ajax.start_quiz( post_id, user_id ); - }, - - /** - * Answer Question - * Finds values of quiz-id, question-type, question-id and answer - * Calls ajax.answer_question - * - * @return {[void]} - */ - answer_question: function() { - - if ( $( 'input[name=llms_option_selected]:checked' ).length <= 0 ){ - - $('#llms-quiz-question-wrapper .llms-error').remove(); - $('#llms-quiz-question-wrapper') - .prepend( '
You must enter an answer to continue.
' ); - - } else { - - var quiz_id = $('#llms-quiz').val(), - question_type = $('#question-type').val(), - question_id = $('#question-id').val(), - answer = $('input[name=llms_option_selected]:checked').val(), - - ajax = new Ajax('post', { - action : 'answer_question', - quiz_id : quiz_id, - question_type : question_type, - question_id : question_id, - answer : answer - },true ); - - ajax.answer_question( - question_type, - question_id, - answer - ); - - } - - }, - - /** - * Previous Question - * Finds quiz-id and question-id - * Calls ajax.previous_question to find the previous question - * @return {[void]} - */ - previous_question: function() { - - var quiz_id = $('#llms-quiz').val(), - question_id = $('#question-id').val(), - ajax = new Ajax('post', { - action :'previous_question', - quiz_id : quiz_id, - question_id : question_id - }, true); - - ajax.previous_question( quiz_id, question_id ); - }, - - /** - * Start Quiz Timer - * Gets minutes from hidden field - * Not used as actual quiz timer. Quiz is timed on the server from the quiz class - * Calculates minutes to milliseconds and then converts to hours / minutes - * - * When time limit reaches 0 calls complete_quiz() to complete quiz. - * - * @return Calls get_count_down at a set interval of 1 second - */ - start_quiz_timer: function() { - - var total_minutes = $('#set-time').val(); - - if ( total_minutes ) { - - var target_date = new Date().getTime() + ((total_minutes * 60 ) * 1000), // set the countdown date - time_limit = ((total_minutes * 60 ) * 1000), - days, hours, minutes, seconds, // variables for time units - countdown = document.getElementById('tiles'), // get tag element - that = this; - - //set actual timer - setTimeout( - function() { - that.complete_quiz(); - }, time_limit ); - - this.getCountdown( - total_minutes, - target_date, - time_limit, - days, - hours, - minutes, - seconds, - countdown - ); - - //call get_count_down every 1 second - setInterval(function () { - that.getCountdown( - total_minutes, - target_date, - time_limit, - days, - hours, - minutes, - seconds, - countdown - ); - }, 1000 ); - } - }, - - /** - * Get Count Down - * Called every second to update the on screen countdown timer - * Changes color to yellow at 1/2 of total time - * Changes color to red at 1/4 of total time - * @param {[int]} minutes [description] - * @param {[date]} target_date [description] - * @param {[int]} time_limit [description] - * @param {[int]} days [description] - * @param {[int]} hours [description] - * @param {[int]} minutes [description] - * @param {[int]} seconds [description] - * @param {[int]} countdown [description] - * @return Displays updates hours, minutes on quiz timer - */ - getCountdown: function(total_minutes, target_date, time_limit, days, hours, minutes, seconds, countdown){ - - // find the amount of "seconds" between now and target - var current_date = new Date().getTime(), - seconds_left = (target_date - current_date) / 1000; - if ( seconds_left >= 0 ) { - - if ( (seconds_left * 1000 ) < ( time_limit / 2 ) ) { - - $( '#tiles' ).removeClass('color-full'); - $( '#tiles' ).addClass('color-half'); - - } - - if ( (seconds_left * 1000 ) < ( time_limit / 4 ) ) { - - $( '#tiles' ).removeClass('color-half'); - $( '#tiles' ).addClass('color-empty'); - - } - - days = this.pad( parseInt(seconds_left / 86400) ); - seconds_left = seconds_left % 86400; - hours = this.pad( parseInt(seconds_left / 3600) ); - seconds_left = seconds_left % 3600; - minutes = this.pad( parseInt( seconds_left / 60 ) ); - seconds = this.pad( parseInt( seconds_left % 60 ) ); - // format countdown string + set tag value - countdown.innerHTML = '' + hours + ':' + minutes + ':' + seconds + ''; - } - }, - - /** - * Pad Number - * pads number with 0 if single digit. - * @param {[int]} n [number] - * @return {[string]} [padded number] - */ - pad: function(n) { - return (n < 10 ? '0' : '') + n; - }, - - /** - * Complete Quiz - * Called by start_quiz_timer when countdown reaches 0 - * @return Calls ajax.complete_quiz to end quiz - */ - complete_quiz: function() { - - var quiz_id = $('#llms-quiz').val(), - question_type = $('#question-type').val(), - question_id = $('#question-id').val(), - answer = $('input[name=llms_option_selected]:checked').val(), - ajax = new Ajax( 'post', { - action : 'complete_quiz', - quiz_id : quiz_id, - question_id : question_id, - question_type : question_type, - answer : answer - }, true); - ajax.complete_quiz( quiz_id, question_id, question_type, answer ); - } -}; diff --git a/_private/js/app/llms-review.js b/_private/js/app/llms-review.js deleted file mode 100644 index 98372d846e..0000000000 --- a/_private/js/app/llms-review.js +++ /dev/null @@ -1,82 +0,0 @@ -/* global LLMS, $, jQuery */ -/* jshint strict: false */ -/*jshint -W020 */ - -LLMS.Review = { - /** - * init - * loads class methods - */ - init: function() - { - console.log('Initializing Review '); - this.bind(); - }, - - /** - * This function binds actions to the appropriate hooks - */ - bind: function() - { - $('#llms_review_submit_button').click(function() - { - if ($('#review_title').val() !== '' && $('#review_text').val() !== '') - { - jQuery.ajax({ - type : 'post', - dataType : 'json', - url : window.llms.ajaxurl, - data : { - action : 'LLMSSubmitReview', - review_title: $('#review_title').val(), - review_text: $('#review_text').val(), - pageID : $('#post_ID').val() - }, - success: function() - { - console.log('Review success'); - $('#review_box').hide('swing'); - $('#thank_you_box').show('swing'); - }, - error: function(jqXHR, textStatus, errorThrown ) - { - console.log(jqXHR); - console.log(textStatus); - console.log(errorThrown); - }, - }); - } else { - if ($('#review_title').val() === '') - { - $('#review_title_error').show('swing'); - } else { - $('#review_title_error').hide('swing'); - } - if ($('#review_text').val() === '') - { - $('#review_text_error').show('swing'); - } else { - $('#review_text_error').hide('swing'); - } - } - }); - if ( $('#_llms_display_reviews').attr('checked') ) { - $('.llms-num-reviews-top').addClass('top'); - $('.llms-num-reviews-bottom').show(); - - } else { - $('.llms-num-reviews-bottom').hide(); - } - $('#_llms_display_reviews').change(function() { - if ( $('#_llms_display_reviews').attr('checked') ) { - $('.llms-num-reviews-top').addClass('top'); - $('.llms-num-reviews-bottom').show(); - } else { - $('.llms-num-reviews-top').removeClass('top'); - $('.llms-num-reviews-bottom').hide(); - } - }); - - console.log('Review Methods Bound'); - }, -}; diff --git a/_private/js/app/llms-tabs.js b/_private/js/app/llms-tabs.js deleted file mode 100644 index 692329f6cb..0000000000 --- a/_private/js/app/llms-tabs.js +++ /dev/null @@ -1,38 +0,0 @@ -/* global LLMS, $ */ -/* jshint strict: false */ - -/** - * Front End Quiz Class - * Applies only to post type quiz - * @type {Object} - */ -LLMS.Tabs = { - - /** - * init - * loads class methods - */ - init: function() { - this.bind(); - }, - - /** - * Bind Method - * Handles dom binding on load - * @return {[type]} [description] - */ - bind: function() { - //var that = this; - - $('ul.tabs li').click(function(){ - var tab_id = $(this).attr('data-tab'); - - $('ul.tabs li').removeClass('current'); - $('.tab-content').removeClass('current'); - - $(this).addClass('current'); - $('#' + tab_id).addClass('current'); - }); - - } -}; diff --git a/_private/js/app/rest.js b/_private/js/app/rest.js deleted file mode 100644 index b2f4cff74a..0000000000 --- a/_private/js/app/rest.js +++ /dev/null @@ -1,68 +0,0 @@ -/*global LLMS */ -/* jshint strict: false */ - -/** - * Rest Methods - * Manages URL and Rest object parsing - * @type {Object} - */ -LLMS.Rest = { - - /** - * init - * loads class methods - */ - init: function() { - console.log('Initializing Rest Methods '); - this.bind(); - }, - - /** - * Bind Method - * Handles dom binding on load - * @return {[type]} [description] - */ - bind: function() { - console.log('Rest Methods Bound'); - }, - - /** - * Searches for string matches in url path - * @param {Array} strings [Array of strings to search for matches] - * @return {Boolean} [Was a match found?] - */ - is_path: function( strings ) { - - var path_exists = false, - url = window.location.href; - - for( var i = 0; i < strings.length; i++ ) { - - if ( url.search( strings[i] ) > 0 && !path_exists ) { - - path_exists = true; - } - } - - return path_exists; - }, - - /** - * Retrieves query variables - * @return {[Array]} [array object of query variable key=>value pairs] - */ - get_query_vars: function() { - - var vars = [], hash, - hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); - - for(var i = 0; i < hashes.length; i++) { - hash = hashes[i].split('='); - vars.push(hash[0]); - vars[hash[0]] = hash[1]; - } - - return vars; - } - -}; diff --git a/_private/js/llms-ajax.js b/_private/js/llms-ajax.js deleted file mode 100644 index fd5a6e71fd..0000000000 --- a/_private/js/llms-ajax.js +++ /dev/null @@ -1,294 +0,0 @@ -function Ajax (type, data, cache) { - - this.type = type; - this.data = data; - this.cache = cache; - this.dataType = 'json'; - this.url = window.ajaxurl || window.llms.ajaxurl; - -} - -Ajax.prototype.get_sections = function () { - jQuery.ajax({ - type : this.type, - url : this.url, - data : this.data, - cache : this.cache, - dataType : this.dataType, - success : function(response) { section_template(response); } - }); -}; - -Ajax.prototype.get_lesson = function (lesson_id, row_id, type) { - jQuery.ajax({ - type : this.type, - url : this.url, - data : this.data, - cache : this.cache, - dataType : this.dataType, - success : function(response) { add_edit_link(response, lesson_id, row_id, type); }, - }); -}; - -Ajax.prototype.get_lessons = function (section_id, section_position) { - jQuery.ajax({ - type : this.type, - url : this.url, - data : this.data, - cache : this.cache, - dataType : this.dataType, - success : function(response) { lesson_template(response, section_id, section_position); }, - }); -}; - -Ajax.prototype.update_syllabus = function () { - jQuery.ajax({ - // type : this.type, - url : this.url, - data : this.data, - cache : this.cache, - dataType : this.dataType, - success : function(response) { console.log(JSON.stringify(response, null, 4)); }, - error : function(errorThrown){ console.log(errorThrown); }, - }); -}; - -Ajax.prototype.get_all_posts = function () { - jQuery.ajax({ - type : this.type, - url : this.url, - data : this.data, - cache : this.cache, - dataType : this.dataType, - success : function(response) { return_data(response); }, - }); -}; - -Ajax.prototype.get_all_engagements = function () { - jQuery.ajax({ - type : this.type, - url : this.url, - data : this.data, - cache : this.cache, - dataType : this.dataType, - success : function(response) { return_engagement_data(response); }, - }); -}; - -Ajax.prototype.get_associated_lessons = function (section_id, section_position) { - jQuery.ajax({ - type : this.type, - url : this.url, - data : this.data, - cache : this.cache, - dataType : this.dataType, - success : function(response) { add_associated_lessons(response, section_id, section_position); }, - }); -}; - -Ajax.prototype.get_question = function (question_id, row_id) { - jQuery.ajax({ - type : this.type, - url : this.url, - data : this.data, - cache : this.cache, - dataType : this.dataType, - success : function(response) { add_edit_link(response, question_id, row_id); }, - }); -}; - -Ajax.prototype.get_questions = function () { - jQuery.ajax({ - type : this.type, - url : this.url, - data : this.data, - cache : this.cache, - dataType : this.dataType, - success : function(response) { single_question_template(response); }, - }); -}; - -Ajax.prototype.start_quiz = function (quiz_id, user_id) { - jQuery.ajax({ - type : this.type, - url : this.url, - data : this.data, - cache : this.cache, - dataType : this.dataType, - beforeSend: function() { - - jQuery( '#llms_start_quiz' ).hide(); - jQuery('html, body').stop().animate({scrollTop: 0}, 500); - jQuery('#llms-quiz-wrapper').empty(); - - jQuery('#llms-quiz-question-wrapper').append( '
Loading Question...
' ); - - }, - success: function( html ) { - - //start the quiz timer - LLMS.Quiz.start_quiz_timer(); - - //show the quiz timer - jQuery('#llms-quiz-timer').show(); - - //remove the loading message - jQuery('#llms-quiz-question-wrapper #loader').remove(); - - //append the returned html - jQuery('#llms-quiz-question-wrapper').append( html ); - - jQuery('#llms_answer_question').click(function() { - - //call answer question - LLMS.Quiz.answer_question(); - - return false; - - }); - } - }); -}; - -Ajax.prototype.answer_question = function ( quiz_id, question_type, question_id, answer ) { - jQuery.ajax({ - type : this.type, - url : this.url, - data : this.data, - cache : this.cache, - dataType : this.dataType, - beforeSend: function() { - jQuery('#llms-quiz-question-wrapper').empty(); - jQuery('#llms-quiz-question-wrapper').append( '
Loading Next Question...
' ); - }, - success: function( response ) { - - if ( response.redirect ) { - window.location.replace( response.redirect ); - - } else if ( response.message) { - window.location.replace( response.redirect ); - - } else { - - jQuery('#llms-quiz-question-wrapper #loader').remove(); - - jQuery('#llms-quiz-question-wrapper').append( response.html ); - - jQuery('#llms_answer_question').click(function() { - LLMS.Quiz.answer_question(); - return false; - }); - - jQuery('#llms_prev_question').click(function() { - LLMS.Quiz.previous_question(); - return false; - }); - - } - } //end success - }); -}; - -Ajax.prototype.previous_question = function (quiz_id, question_id) { - jQuery.ajax({ - type : this.type, - url : this.url, - data : this.data, - cache : this.cache, - dataType : this.dataType, - beforeSend: function() { - - jQuery('#llms-quiz-question-wrapper').empty(); - jQuery('#llms-quiz-question-wrapper').append( '
Loading Question...
' ); - - }, - success: function( html ) { - - jQuery('#llms-quiz-question-wrapper #loader').remove(); - - jQuery('#llms-quiz-question-wrapper').append( html ); - - jQuery('#llms_answer_question').click(function() { - LLMS.Quiz.answer_question(); - return false; - }); - - jQuery('#llms_prev_question').click(function() { - LLMS.Quiz.previous_question(); - return false; - }); - } - - }); -}; - -Ajax.prototype.complete_quiz = function ( quiz_id, question_id, question_type, answer ) { - jQuery.ajax({ - type : this.type, - url : this.url, - data : this.data, - cache : this.cache, - dataType : this.dataType, - beforeSend: function() { - - jQuery('#llms-quiz-question-wrapper').empty(); - jQuery('#llms-quiz-question-wrapper').append( '
Loading Quiz Results...
' ); - - }, - success: function( response ) { - - //redirect back to quiz page - window.location.replace( response.redirect ); - - } //end success - }); -}; - -Ajax.prototype.getLessons = function () { - jQuery.ajax({ - type : this.type, - url : this.url, - data : this.data, - cache : this.cache, - dataType : this.dataType, - success : function(response) { return_data(response); }, - }); -}; - -Ajax.prototype.getSections = function () { - jQuery.ajax({ - type : this.type, - url : this.url, - data : this.data, - cache : this.cache, - dataType : this.dataType, - success : function(response) { return_data(response); }, - }); -}; - -Ajax.prototype.get_course_tracks = function () { - jQuery.ajax({ - type : this.type, - url : this.url, - data : this.data, - cache : this.cache, - dataType : this.dataType, - success : function(response) { return_data(response); }, - }); -}; - - -Ajax.prototype.check_voucher_duplicate = function () { - - jQuery.ajax({ - type : this.type, - url : this.url, - data : this.data, - cache : this.cache, - dataType : this.dataType, - success : function(response) { - llms_on_voucher_duplicate(response.duplicates); - } - }); -}; diff --git a/_private/js/llms-analytics.js b/_private/js/llms-analytics.js deleted file mode 100644 index 7d7d59daa9..0000000000 --- a/_private/js/llms-analytics.js +++ /dev/null @@ -1,296 +0,0 @@ -jQuery(document).ready(function($) { - - - var chosen_config = { - '.chosen-select' : {}, - '.chosen-select-deselect' : {allow_single_deselect:true}, - '.chosen-select-no-single' : {disable_search_threshold:10}, - '.chosen-select-no-results': {no_results_text:'Oops, nothing found!'}, - '.chosen-select-width' : {width:"100%"} - }; - - for ( var selector in chosen_config ) { - $( selector).chosen(chosen_config[selector] ); - } - - $( '.llms-date-range-select-start' ).datepicker(); - $( '.llms-date-range-select-end' ).datepicker(); - - - - - - - - var query_vars = get_query_var(); - if ( ( query_vars.page === 'llms-analytics' && query_vars.tab === 'sales' ) || - ( query_vars.page === 'llms-analytics' && ! ( 'tab' in query_vars ) ) ) { - - google.setOnLoadCallback(drawChart); - - $(window).resize(function(){ - drawChart(); - }); - - } else if ( query_vars.page === 'llms-analytics' && query_vars.tab === 'courses' ) { - - google.setOnLoadCallback(drawChart2); - google.setOnLoadCallback(drawChart3); - - - - if ( $( window ).width() <= 768 ) { - google.setOnLoadCallback(drawTableSmall); - } else { - google.setOnLoadCallback(drawTable); - } - - $(window).resize(function(){ - if ( $( window ).width() <= 768 ) { - drawTableSmall(); - } else { - drawTable(); - } - - drawChart2(); - drawChart3(); - - }); - - } else if ( query_vars.page === 'llms-analytics' && query_vars.tab === 'memberships' ) { - - google.setOnLoadCallback( draw_enrolled_members_chart ); - - if ( $( window ).width() <= 768 ) { - google.setOnLoadCallback( draw_member_table_small ); - } else { - google.setOnLoadCallback( draw_member_table ); - } - - $(window).resize(function(){ - if ( $( window ).width() <= 768 ) { - draw_member_table_small(); - } else { - draw_member_table(); - } - - draw_enrolled_members_chart(); - - }); - - } else if ( ( query_vars.page === 'llms-students' && ! ( 'tab' in query_vars ) ) - || ( query_vars.page === 'llms-students' && query_vars.tab === 'dashboard' ) ) { - - //manage expired users checkbox for students search screen - //if all products is selected then hide and uncheck the show expired users filter - if ( $( '.chosen-select-width').chosen().val() === 'all_products' ) { - $( '#include_expired_users' ).hide(); - $( '#exp_users_filter' ).attr('checked', false); - } - //on checkbox selection if the expired users filter is hidden then display it. - $( '.chosen-select-width').chosen().change( function() { - if ( $( '.chosen-select-width').chosen().val() == 'all_products' ) { - $( '#include_expired_users' ).hide(); - $( '#exp_users_filter' ).attr('checked', false); - } else { - $( '#include_expired_users' ).show(); - } - }); - - //get search results table - google.setOnLoadCallback( draw_student_search_results_table ); - - $(window).resize(function(){ - - draw_student_search_results_table() - - }); - - } else if ( query_vars.page === 'llms-students' && query_vars.tab === 'profile' ) { - - google.setOnLoadCallback( draw_student_course_table ); - google.setOnLoadCallback( draw_student_membership_table ); - - $(window).resize(function(){ - draw_student_course_table() - }); - - } - - - -}); - -google.load("visualization", "1", {packages:["corechart", "table"]}); - -get_query_var = function() { - var vars = [], hash; - var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); - for(var i = 0; i < hashes.length; i++) { - hash = hashes[i].split('='); - vars.push(hash[0]); - vars[hash[0]] = hash[1]; - } - return vars; -} - - - - function drawChart() { - var data = google.visualization.arrayToDataTable(myJson); - - var options = { - title: 'Sales Volume', - hAxis: {title: 'Date Range', titleTextStyle: {color: '#333'}}, - vAxis: {minValue: 0} - }; - - var chart = new google.visualization.AreaChart(document.getElementById('chart_div')); - chart.draw(data, options); - } - - function drawChart2() { - var data = google.visualization.arrayToDataTable(enrolled_students); - - var options = { - title: 'Student Enrollment', - //curveType: 'function', - legend: { position: 'bottom' } - }; - - var chart = new google.visualization.LineChart(document.getElementById('curve_chart')); - - chart.draw(data, options); - } - - function drawChart3() { - var chart_height = ( ( lesson_completion_percent.length * 50 ) + 100 ); - var data = google.visualization.arrayToDataTable(lesson_completion_percent); - - var options = { - title: 'Lesson Completion Percentage', - legend: { position: 'bottom' }, - height: chart_height, - hAxis: {title: 'Percentage', titleTextStyle: {color: '#333'}, minValue: 0, maxValue: 100 }, - vAxis: { title: 'Lesson' } - }; - - var chart = new google.visualization.BarChart(document.getElementById('lesson-completion-chart')); - chart.draw(data, options); - } - - - function drawTable() { - var data = new google.visualization.DataTable(); - data.addColumn('string', 'Last'); - data.addColumn('string', 'First'); - data.addColumn('string', 'Enrolled'); - data.addColumn('string', 'Completion'); - data.addColumn('string', 'Last Lesson Completed'); - data.addColumn('string', 'View'); - data.addRows(students_result_large); - - var table = new google.visualization.Table(document.getElementById('table_div')); - - table.draw(data, {showRowNumber: true, allowHtml: true}); - } - - function drawTableSmall() { - var data = new google.visualization.DataTable(); - data.addColumn('string', 'Last'); - data.addColumn('string', 'First'); - data.addColumn('string', 'View'); - data.addRows(students_result_small); - - var table = new google.visualization.Table(document.getElementById('table_div')); - - table.draw(data, {showRowNumber: true, allowHtml: true}); - } - - - - function draw_enrolled_members_chart() { - var data = google.visualization.arrayToDataTable(enrolled_members); - - var options = { - title: 'Membership Enrollment by Day', - //curveType: 'function', - legend: { position: 'bottom' } - }; - - var chart = new google.visualization.LineChart(document.getElementById('enrolled_members_chart')); - - chart.draw(data, options); - } - - - - function draw_member_table() { - - var data = new google.visualization.DataTable(); - data.addColumn('string', 'Last'); - data.addColumn('string', 'First'); - data.addColumn('string', 'Enrolled'); - data.addColumn('string', 'Expires'); - data.addColumn('string', 'View'); - data.addRows(members_result_large); - - var table = new google.visualization.Table(document.getElementById('members_table')); - - table.draw(data, {showRowNumber: true, allowHtml: true}); - } - - function draw_member_table_small() { - - var data = new google.visualization.DataTable(); - data.addColumn('string', 'Last'); - data.addColumn('string', 'First'); - data.addColumn('string', 'View'); - data.addRows(members_result_small); - - var table = new google.visualization.Table(document.getElementById('members_table')); - - table.draw(data, {showRowNumber: true, allowHtml: true}); - } - - - function draw_student_search_results_table() { - - var data = new google.visualization.DataTable(); - data.addColumn('string', 'Last'); - data.addColumn('string', 'First'); - data.addColumn('string', 'Email'); - data.addColumn('string', 'View'); - data.addRows(students_search_result_large); - - var table = new google.visualization.Table(document.getElementById('student_search_results')); - - table.draw(data, {showRowNumber: true, allowHtml: true}); - } - - function draw_student_course_table() { - - var data = new google.visualization.DataTable(); - data.addColumn('string', 'Course'); - data.addColumn('string', 'Enrolled Date'); - data.addColumn('string', 'Status'); - data.addColumn('string', 'Progress'); - data.addRows(student_course_list); - - var table = new google.visualization.Table(document.getElementById('student_course_table')); - - table.draw(data, {showRowNumber: true, allowHtml: true}); - } - - function draw_student_membership_table() { - - var data = new google.visualization.DataTable(); - data.addColumn('string', 'membership'); - data.addColumn('string', 'Enrolled Date'); - data.addColumn('string', 'Status'); - data.addRows(student_membership_list); - - var table = new google.visualization.Table(document.getElementById('student_membership_table')); - - table.draw(data, {showRowNumber: true, allowHtml: true}); - } diff --git a/_private/js/llms-form-checkout.js b/_private/js/llms-form-checkout.js deleted file mode 100644 index cacac81ecf..0000000000 --- a/_private/js/llms-form-checkout.js +++ /dev/null @@ -1,77 +0,0 @@ -jQuery(document).ready(function($) { - - $('#llms_country_options').chosen(); - - //display coupon redemption form on link click - get_current_price(); - - $('#show-coupon').on( 'click', display_coupon_form ); - - $('.llms-payment-options input[type=radio]').change(display_current_price); - - if ($('.llms-payment-methods input[type=radio]').length) { - if ($('.llms-payment-methods input[type=radio]:checked').data('payment-type') == 'creditcard') { - - $('.llms-creditcard-fields').show(); - } - - } - - $('.llms-payment-methods input[type=radio]').change(display_credit_card_fields); - - //$('.llms-price-option-radio').on('change', display_current_price ); - -}); - -(function($){ -display_credit_card_fields = function() { - if ($(this).data('payment-type') == 'creditcard') { - $('.llms-creditcard-fields').slideDown('fast'); - } - else { - $('.llms-creditcard-fields').slideUp('fast'); - } -}; -})(jQuery); - -(function($){ -display_coupon_form = function() { - - // Hide the show coupon link - $(this).hide(); - $('#llms-checkout-coupon').show().slideDown('slow'); - return false; -}; -})(jQuery); - -(function($){ -display_current_price = function() { - var target_id = $(this).attr('id'); - - var price = $('#' + target_id).parent().find('label').text(); - - $('.llms-final-price').text(price); - - // Hide the show coupon link - // $(this).hide(); - // $('#llms-checkout-coupon').show(); - // return false; -}; -})(jQuery); - -(function($){ -get_current_price = function() { - - var price = $('.llms-payment-options input[type=radio]:checked'); - var target_id = $(price).attr('id'); - - var price = $('#' + target_id).parent().find('label').text(); - - $('.llms-final-price').text(price); - - // Hide the show coupon link - // $(this).hide(); - // $('#llms-checkout-coupon').show(); - // return false; -}; -})(jQuery); \ No newline at end of file diff --git a/_private/js/llms-lesson-locked.js b/_private/js/llms-lesson-locked.js deleted file mode 100644 index d6a4036ed4..0000000000 --- a/_private/js/llms-lesson-locked.js +++ /dev/null @@ -1,20 +0,0 @@ -jQuery(document).ready(function($) { - var tip = $('.llms-lesson-tooltip'); - - $( '.llms-lesson-link-locked' ).click(function(e) { - e.preventDefault(); - var el = $(this); - var thistip = el.find('.llms-lesson-tooltip'); - - if(!thistip.length) { - el.append(tip.clone()); - thistip = el.find('.llms-lesson-tooltip'); - thistip.html(el.attr("title")); - } - - thistip.toggleClass('active'); - }) -}); - - - diff --git a/_private/js/llms-metabox-achievement.js b/_private/js/llms-metabox-achievement.js deleted file mode 100644 index b65dabb613..0000000000 --- a/_private/js/llms-metabox-achievement.js +++ /dev/null @@ -1,62 +0,0 @@ -jQuery(document).ready(function($){ - - $('.achievement_image_button').click(function(e) { - - //Create Media Manager On Click to allow multiple on one Page - var achievement_uploader; - - e.preventDefault(); - - //Setup the Variables based on the Button Clicked to enable multiple - var achievement_img_input_id = '#'+this.id+'.upload_achievement_image'; - var achievement_img_src = 'img#'+this.id+'.llms_achievement_image'; - - - //If the uploader object has already been created, reopen the dialog - if (achievement_uploader) { - achievement_uploader.open(); - return; - } - - //Extend the wp.media object - achievement_uploader = wp.media.frames.file_frame = wp.media({ - title: 'Choose Achievement Image', - button: { - text: 'Choose Achievement' - }, - multiple: false - }); - - //When a file is selected, grab the URL and set it as the text field's value - achievement_uploader.on('select', function() { - attachment = achievement_uploader.state().get('selection').first().toJSON(); - //Set the Field with the Image ID - $(achievement_img_input_id).val(attachment.id); - //Set the Sample Image with the URL - $(achievement_img_src).attr('src', attachment.url); - - }); - - //Open the uploader dialog - achievement_uploader.open(); - - }); - -}); -/* -* Media Manager 3.5 -* @version 1.70 -*/ -jQuery(document).ready(function($){ - //Remove Image and replace with default and Erase Image ID for achievement - $('.llms_achievement_clear_image_button').click(function(e) { - e.preventDefault(); - var achievement_remove_input_id = 'input#'+this.id+'.upload_achievement_image'; - var achievement_img_src = 'img#'+this.id+'.llms_achievement_image'; - var achievement_default_img_src = $('img#'+this.id+'.llms_achievement_default_image').attr("src"); - - $(achievement_remove_input_id).val(''); - $(achievement_img_src).attr('src', achievement_default_img_src); - }); - -}); \ No newline at end of file diff --git a/_private/js/llms-metabox-certificate.js b/_private/js/llms-metabox-certificate.js deleted file mode 100644 index 981e855a8a..0000000000 --- a/_private/js/llms-metabox-certificate.js +++ /dev/null @@ -1,62 +0,0 @@ -jQuery(document).ready(function($){ - - $('.certificate_image_button').click(function(e) { - - //Create Media Manager On Click to allow multiple on one Page - var certificate_uploader; - - e.preventDefault(); - - //Setup the Variables based on the Button Clicked to enable multiple - var certificate_img_input_id = '#'+this.id+'.upload_certificate_image'; - var certificate_img_src = 'img#'+this.id+'.llms_certificate_image'; - - - //If the uploader object has already been created, reopen the dialog - if (certificate_uploader) { - certificate_uploader.open(); - return; - } - - //Extend the wp.media object - certificate_uploader = wp.media.frames.file_frame = wp.media({ - title: 'Choose Certificate Image', - button: { - text: 'Choose Certificate' - }, - multiple: false - }); - - //When a file is selected, grab the URL and set it as the text field's value - certificate_uploader.on('select', function() { - attachment = certificate_uploader.state().get('selection').first().toJSON(); - //Set the Field with the Image ID - $(certificate_img_input_id).val(attachment.id); - //Set the Sample Image with the URL - $(certificate_img_src).attr('src', attachment.url); - - }); - - //Open the uploader dialog - certificate_uploader.open(); - - }); - -}); -/* -* Media Manager 3.5 -* @version 1.70 -*/ -jQuery(document).ready(function($){ - //Remove Image and replace with default and Erase Image ID for Certificate - $('.llms_certificate_clear_image_button').click(function(e) { - e.preventDefault(); - var certificate_remove_input_id = 'input#'+this.id+'.upload_certificate_image'; - var certificate_img_src = 'img#'+this.id+'.llms_certificate_image'; - var certificate_default_img_src = $('img#'+this.id+'.llms_certificate_default_image').attr("src"); - - $(certificate_remove_input_id).val(''); - $(certificate_img_src).attr('src', certificate_default_img_src); - }); - -}); \ No newline at end of file diff --git a/_private/js/llms-metabox-data.js b/_private/js/llms-metabox-data.js deleted file mode 100644 index e86182845e..0000000000 --- a/_private/js/llms-metabox-data.js +++ /dev/null @@ -1,76 +0,0 @@ -jQuery(document).ready(function($) { - - if($('#_sale_price').length) { - toggle_sales_fields(); - } - - if($('#_llms_subscription_price').length) { - toggle_recurring_fields(); - } - - $('#cancel-sale').on('click', function () { - clear_fields(["#_sale_price", "#_sale_price_dates_from", "#_sale_price_dates_to"]); - return false; - }); - -}); - -//Toggle sales fields -(function($){ - toggle_sales_fields = function() { - - if ($('#_sale_price').val().length > 0) { - $("#checkme").prop('checked', true); - $("#extra").show("fast"); - } - else { - //Hide div w/id extra - $("#extra").css("display","none"); - } - - $("#checkme").click(function(){ - toggle_sales_fields(); - }); - - if ($("#checkme").is(":checked")) - { - //show the hidden div - $("#extra").show("fast"); - } - else - { - //otherwise, hide it - $("#extra").hide("fast"); - } - } -})(jQuery); - - -//Toggle Recurring Payment Fields -(function($){ - toggle_recurring_fields = function() { - - if ($('#_llms_subscription_price').val().length > 0) { - $("#recurring_options").show("fast"); - } - else { - //Hide div w/id extra - $("#recurring_options").css("display","none"); - } - - $("#_llms_recurring_enabled").click(function(){ - toggle_recurring_fields(); - }); - - if ($("#_llms_recurring_enabled").is(":checked")) - { - //show the hidden div - $("#recurring_options").show("fast"); - } - else - { - //otherwise, hide it - $("#recurring_options").hide("fast"); - } - } -})(jQuery); \ No newline at end of file diff --git a/_private/js/llms-metabox-engagement.js b/_private/js/llms-metabox-engagement.js deleted file mode 100644 index 653fafadad..0000000000 --- a/_private/js/llms-metabox-engagement.js +++ /dev/null @@ -1,149 +0,0 @@ -jQuery(document).ready(function($) { - - $('#_llms_trigger_type').change(function() { - console.log('LLMS Engagement Trigger Changed'); - - var triggerOptionSelected = $("option:selected", this); - var triggerValueSelected = this.value; - - if (triggerValueSelected == 'lesson_completed') { - console.log('LLMS Engagement: Begin Lesson Query'); - var lessons = get_all_lessons(); - console.log('LLMS Engagement: End Lesson Query'); - } - else if (triggerValueSelected == 'section_completed') { - console.log('LLMS Engagement: Begin Section Query'); - var sections = get_all_sections(); - console.log('LLMS Engagement: End Section Query'); - } - else if (triggerValueSelected == 'course_completed') { - console.log('LLMS Engagement: Begin Course Query'); - var courses = get_all_courses(); - console.log('LLMS Engagement: End Course Query'); - } - else if (triggerValueSelected == 'course_purchased') { - console.log('LLMS Engagement: Begin Course Query'); - var courses = get_all_courses(); - console.log('LLMS Engagement: End Course Query'); - } - else if (triggerValueSelected == 'course_track_completed') { - console.log('LLMS Engagement: Begin Course Track Query'); - var course_tracks = get_all_course_tracks(); - console.log('LLMS Engagement: End Course Track Query'); - } - else { - clear_trigger_select(); - } - }); - - - $('#_llms_engagement_type').change(function() { - var engOptionSelected = $("option:selected", this); - var engValueSelected = this.value; - - if (engValueSelected == 'email') { - var emails = get_all_emails(); - } - if (engValueSelected == 'achievement') { - var achievements = get_all_achievements(); - } - if (engValueSelected == 'certificate') { - var certificates = get_all_certificates(); - } - else { - clear_engagement_select(); - } - - }); - -}); - -return_data = function (response) { - clear_trigger_select(); - - var th = document.createElement('th'); - - var label = document.createElement("Label"); - label.setAttribute("for",'trigger-select'); - label.innerHTML = "Engagement Trigger"; - th.appendChild(label); - - var td = document.createElement("td"); - - var select = document.createElement('select'); - select.setAttribute('id', 'trigger-select'); - select.setAttribute('class', 'chosen-select chosen select section-select'); - select.setAttribute('name', '_llms_engagement_trigger'); - - td.appendChild(select); - jQuery(select).chosen({width:"300px"}); - - if (!jQuery('#trigger-select').length) { - - // populate select with sections. - jQuery(select).append(''); - for (var key in response) { - if (response.hasOwnProperty(key)) { - var option = jQuery(''); - for (var key in response) { - if (response.hasOwnProperty(key)) { - var option = jQuery('' - jQuery(select).append(option); - //jQuery(select).prepend(''); - } - } - jQuery(select).prepend(''); - jQuery('.question-select').chosen(); - jQuery('#question_' + order + ' .question-select').change(function() { get_edit_link(jQuery(this)); }); - - delete_option(); - order_single_options(); - jQuery('.llms-points').blur(function () { - llms_total_points(); - }); -}; - -delete_option = function() { - jQuery('.deleteBtn').click(function() { - var contentPanelId = jQuery(this).attr("class"); - jQuery(this).parent().parent().remove(); - order_single_options(); - }); -} - -/** - * Sortable function - */ -single_option_sortable = function() { - - jQuery('.question-list').sortable({ - items : '.list_item', - axis : 'y', - placeholder : "placeholder", - cursor : "move", - forcePlaceholderSize:true, - helper : function(e, tr) { - var jQueryoriginals = tr.children(); - var jQueryhelper = tr.clone(); - jQueryhelper.children().each(function(index) - { - jQuery(this).width(jQueryoriginals.eq(index).width()) - }); - return jQueryhelper; - }, - start : function(event, ui) { - var start_pos = ui.item.index(); - ui.item.data('start_pos', start_pos); - }, - update : function(event, ui) { - var start_pos = ui.item.data('start_pos'); - var end_pos = jQuery(ui.item).index(); - jQuery(ui.item).attr("data-order", end_pos); - order_single_options(); - - - } - }); -} - -order_single_options = function() { - jQuery("#llms-single-options tr").each( function(index) { - jQuery(this).attr("data-order", index); - jQuery(this).attr("id", 'question_' + index); - jQuery(this).find('.question-select').each( function() { - jQuery(this).attr("id", 'question_select_' + index); - }); - }); -} - -/** - * Returns array of all questions - */ -get_questions = function() { - var ajax = new Ajax('post', {'action':'get_questions'}, true); - ajax.get_questions(); -} - -get_edit_link = function(element) { - console.log('get edit link called'); - console.log(element); - var question_id = jQuery(element).val(); - var element_id = jQuery(element).attr('id'); - console.log('element_id'); - console.log(element_id); - - console.log(question_id); - var ajax = new Ajax('post', {'action':'get_question', 'question_id' : question_id}, true); - ajax.get_question(question_id, element_id); -} -add_edit_link = function(post, question_id, row_id) { - console.log('add_edit_link called'); - console.log(question_id); - console.log(post); - console.log(row_id); - - var edit_link = document.createElement('a'); - edit_link.setAttribute('href', encodeURI(post.edit_url)); - - var edit_icon = document.createElement('i'); - edit_icon.setAttribute('class', 'fa fa-pencil-square-o llms-fa-edit '); - - edit_link.appendChild(edit_icon); - jQuery('#' + row_id).parent().parent().find('.llms-fa-edit').hide(); - jQuery('#' + row_id).parent().next().next().append(edit_link); - - -} diff --git a/_private/js/llms-metabox-single-question.js b/_private/js/llms-metabox-single-question.js deleted file mode 100644 index 8dcb0c44c5..0000000000 --- a/_private/js/llms-metabox-single-question.js +++ /dev/null @@ -1,101 +0,0 @@ -jQuery(document).ready(function($) { - -$('#add_new_option').click(function() { - single_course_template(); - return false; -}); - -$('#publish').click(function() { - update_question_options(); -}); - -delete_option(); -single_option_sortable(); - - -}); - - /** - * Generate single choice question template - */ -single_course_template = function () { - var order = (jQuery("#llms-single-options tr").length); - - jQuery(' \ - - \ - \ - - \ - -
- - - - - ').appendTo('#llms-single-options .dad-list tbody').hide().fadeIn(300); - - delete_option(); -}; - -delete_option = function() { - jQuery('.deleteBtn').click(function() { - var contentPanelId = jQuery(this).attr("class"); - jQuery(this).parent().parent().remove(); - order_single_options(); - }); -} - -/** - * Sortable function - */ -single_option_sortable = function() { - - jQuery('.dad-list').sortable({ - items : '.list_item', - axis : 'y', - placeholder : "placeholder", - cursor : "move", - forcePlaceholderSize:true, - helper : function(e, tr) { - var jQueryoriginals = tr.children(); - var jQueryhelper = tr.clone(); - jQueryhelper.children().each(function(index) - { - jQuery(this).width(jQueryoriginals.eq(index).width()) - }); - return jQueryhelper; - }, - start : function(event, ui) { - var start_pos = ui.item.index(); - ui.item.data('start_pos', start_pos); - var radio_checked= {}; - - var radio_checked= {}; - jQuery('input[type="radio"]', this).each(function(){ - if(jQuery(this).is(':checked')) - radio_checked[jQuery(this).attr('name')] = jQuery(this).val(); - jQuery(document).data('radio_checked', radio_checked); - }); - }, - update : function(event, ui) { - var start_pos = ui.item.data('start_pos'); - var end_pos = jQuery(ui.item).index(); - jQuery(ui.item).attr("data-order", end_pos); - - } - }).bind('sortstop', function (event, ui) { - var radio_restore = jQuery(document).data('radio_checked'); - jQuery.each(radio_restore, function(index, value){ - jQuery('input[name="'+index+'"][value="'+value+'"]').prop('checked', true); - }); - order_single_options(); - }); -} - -order_single_options = function() { - jQuery("#llms-single-options tr").each( function(index) { - jQuery(this).attr("data-order", index); - var option = jQuery(this).find('input[type="radio"]').val(index); - }); -} diff --git a/_private/js/llms-metabox-students.js b/_private/js/llms-metabox-students.js deleted file mode 100644 index 14e419e2ea..0000000000 --- a/_private/js/llms-metabox-students.js +++ /dev/null @@ -1,66 +0,0 @@ -jQuery(document).ready(function($) { - jQuery(".add-student-select").select2({ - width: '100%', - multiple: true, - allowClear: true, - maximumSelectionLength: 10, - placeholder: "Select a student", - ajax: { - url: "admin-ajax.php", - method: 'POST', - dataType: 'json', - delay: 250, - data: function (params) { - return { - term: params.term, // search term - page: params.page, - action: 'get_students', - postId: jQuery('#post_ID').val(), - }; - }, - processResults: function (data) { - return { - results: $.map(data.items, function (item) { - return { - text: item.name, - id: item.id - } - }) - }; - }, - cache: true, - }, - }); - - jQuery(".remove-student-select").select2({ - width: '100%', - multiple: true, - maximumSelectionLength: 10, - placeholder: "Select a student", - ajax: { - url: "admin-ajax.php", - method: 'POST', - dataType: 'json', - delay: 250, - data: function (params) { - return { - term: params.term, // search term - page: params.page, - action: 'get_enrolled_students', - postId: jQuery('#post_ID').val(), - }; - }, - processResults: function (data) { - return { - results: $.map(data.items, function (item) { - return { - text: item.name, - id: item.id - } - }) - }; - }, - cache: true, - } - }); -}); diff --git a/_private/js/llms-metabox-syllabus.js b/_private/js/llms-metabox-syllabus.js deleted file mode 100644 index 3ac80b6b40..0000000000 --- a/_private/js/llms-metabox-syllabus.js +++ /dev/null @@ -1,558 +0,0 @@ -jQuery(document).ready(function($) { - // set up chosen dropdown - var config = { - '.chosen-select' : {}, - '.chosen-select-deselect' : {allow_single_deselect:true}, - '.chosen-select-no-single' : {disable_search_threshold:10}, - '.chosen-select-no-results': {no_results_text:'Oops, nothing found!'}, - '.chosen-select-width' : {width:"95%"} - } - - for (var selector in config) { - $(selector).chosen(config[selector]); - } - - // set data element "last_selected" to current selected value on page load - $("select").each(function () { - reverse_selection(this); - }); - - // set data element "last_selected" to current selected value before change - $('.section-select').click(function() { - reverse_selection(this); - }); - - //disable selections on page load - $('.section-select').attr('disabled', 'disbaled'); - $('.lesson-select').attr('disabled', 'disbaled'); - - // check for duplicate sections on select change - $('.section-select').change(function() { - //catch_duplicates(this); - //$(this).attr('disabled', 'disbaled'); - }); - - // calls ajax update function on lesson change - $('.lesson-select').change(function() { - update_syllabus(); - //$(this).attr('disabled', 'disbaled'); - }); - - // creates new section on Add a new Section button click - $('#addNewSection').click(function(e){ - add_new_section(); - return false; - }); - - // Creates new lesson tr element on Add Lesson button click - $('.addNewLesson').click(function( event ){ - add_new_lesson(event); - return false; - }); - - // deletes the parent element and updates syllabus when delete button clicked - $('.deleteBtn').click(function(){ - delete_this(this) - return false; - }); - - // deletes the parent element and updates syllabus when delete button clicked - $('.section-dismiss').click(function(){ - delete_this(this) - return false; - }) - - // Sets lesson tr elements to sortable on page load - lessons_sortable(); - load_ajax_animation(); - sections_sortable(); - order_lessons(); - - -}); - -/** - * Sets the currently selected element in the dropdown as the last_selected data element - */ -reverse_selection = function( element ) { - jQuery(element).data( 'last_selected', jQuery(element).val() ); -}; - -/** - * Return an alert message when a duplicate section is selected - */ -catch_blanks = function (){ - jQuery('.section-select').each(function () { - if ( jQuery(this).val() == null || jQuery(this).val() == '' ) { - alert( 'Unable to save. Please make sure all of your sections are assigned.' ); - } - else { - update_syllabus(); - } - }); -} - -catch_duplicates = function(element){ - var that = jQuery(this); - var names = []; - var new_value = jQuery(element).val(); - var old_value = jQuery(element).data('last_selected'); - - jQuery('.section-select').each(function () { - - if (new_value == jQuery(this).val()) { - names.push(jQuery(this).val()) - } - //TODO im starting to really need a message class - if (names.length > 1){ - alert("You cannot select a section already assigned to this course."); - jQuery(element).val(old_value).attr("selected", true); - return false; - } - }); - - var promise = wait(); - promise.done(update_syllabus); - var section_position = jQuery(element).parent().parent().attr('id'); - get_associated_lessons(new_value, section_position); -} - -function wait() { - var deferred = jQuery.Deferred(); - - setTimeout(function() { - deferred.resolve(); - }, 2500); - - return deferred.promise(); -} - -/** - * Click event function to append a new row to the tasks table - */ -lessons_sortable = function() { - - jQuery('.dad-list').sortable({ - items : '.list_item', - axis : 'y', - placeholder : "placeholder", - cursor : "move", - forcePlaceholderSize:true, - helper : function(e, tr) { - var jQueryoriginals = tr.children(); - var jQueryhelper = tr.clone(); - jQueryhelper.children().each(function(index) - { - jQuery(this).width(jQueryoriginals.eq(index).width()) - }); - return jQueryhelper; - }, - start : function(event, ui) { - var start_pos = ui.item.index(); - ui.item.data('start_pos', start_pos); - }, - update : function(event, ui) { - var start_pos = ui.item.data('start_pos'); - var end_pos = jQuery(ui.item).index(); - - jQuery(ui.item).attr("data-order", end_pos); - order_lessons(); - update_syllabus(); - } - }); -} - -order_lessons = function() { - - jQuery('.course-section').each( function(index) { - var section_position = jQuery(this).attr('id'); - jQuery(this).find('.list_item').each( function(index) { - jQuery(this).attr("data-order", index + 1); - jQuery(this).attr("id", 'row_' + section_position + '_' + (index + 1)); - }); - }); - jQuery('.course-section').each( function(index) { - var section_position = jQuery(this).attr('id'); - jQuery(this).find('.lesson-select').each( function(index) { - jQuery(this).attr("data-order", index + 1); - jQuery(this).attr("id", 'list_item_' + section_position + '_' + (index + 1)); - }); - }); - jQuery('.course-section').each( function(index) { - console.log(index); - var section_position = jQuery(this).attr('id'); - jQuery(this).find('.section-select').each( function(index) { - console.log('-------------------------------'); - console.log(section_position) - jQuery(this).attr("id", 'section_item_' + section_position); - }); - }); -} - -/** - * Click event function to append a new row to the tasks table - */ -sections_sortable = function() { - - jQuery('#syllabus').sortable({ - items : '.course-section', - axis : 'y', - placeholder : "sortable-placeholder section-placeholder", - cursor : "move", - start : function(event, ui) { - var start_pos = ui.item.index(); - ui.item.data('start_pos', start_pos); - }, - update : function(event, ui) { - var start_pos = ui.item.data('start_pos'); - var end_pos = jQuery(ui.item).index(); - - jQuery(ui.item).attr("data-order", end_pos); - jQuery('.course-section').each( function(index) { - jQuery( this ).attr('id', index + 1 ) - jQuery( this ).find('label').text('Section ' + (index + 1) + ':'); - jQuery( this ).find('a.add-lesson').attr('data-section', index + 1); - - }); - order_lessons(); - update_syllabus(); - } - }); -} - -/** - * get current sections from page - */ -get_sections = function() { - var request_obj = []; - var i = 0; - - jQuery('#syllabus .section-select').each(function() { - i++; - var obj = {}; - var section_id = jQuery(this).val(); - - obj['section_id'] = jQuery(this).val(); - obj['position'] = i; - - var order = jQuery(this).parent().parent().attr('id'); - jQuery( '#' + order ).find( "a" ).attr("data-section_id", section_id); - jQuery( '#' + order ).find( "tr" ).attr("data-section_id", section_id); - - obj['lessons'] = parse_lessons (section_id); - - request_obj.push(obj); - }); - return request_obj; -} - -/** - * Parse through all lessons and build lesson to section arrays. - */ -parse_lessons = function(section_id) { - var section_id = section_id - var lessons = []; - - jQuery('.course-section tbody select').each(function() { - - var parent_position = jQuery(this).parent().parent().parent().parent().parent().attr("id"); - var rowId = (jQuery('#' + parent_position + ' .list_item').length) + 1; - - var lesson_obj = {}; - - lesson_obj['lesson_id'] = jQuery(this).val(); - - var position = jQuery(this).parent().parent().attr("data-order"); - - position = position.substr(position.lastIndexOf("_") + 1); - - lesson_obj['position'] = position; - - if(jQuery(this).parent().parent().attr("data-section_id") == section_id) { - lessons.push(lesson_obj); - } - - }); - return lessons; -} - -/** - * Main update function, updates sections and lessons via ajax class. - */ -update_syllabus = function() { - console.log('update syllabus called'); - var request_obj = get_sections(); - - var data = { 'action':'update_syllabus', 'post_id' : jQuery('#syllabus').data("post_id"), 'sections' : request_obj }; - - var ajax = new Ajax('post', data, false); - ajax.update_syllabus(); -} - -/** - * Find lessons associated with selected section - */ -get_associated_lessons = function(section_id, section_position) { - console.log('get_associated_lessons called'); - var ajax = new Ajax('post', {'action':'get_associated_lessons', 'section_id' : section_id, 'section_position' : section_position }, true); - ajax.get_associated_lessons(section_id, section_position); -} - -add_associated_lessons = function(response, section_id, section_position) { - console.log('add_associated_lessons triggered'); - console.log(response); - console.log(section_id); - console.log(section_position); - associated_lesson_template(response, section_id, section_position) -} - -/** - * Returns array of all lessons - */ -get_lessons = function(section_id, section_position) { - var ajax = new Ajax('post', {'action':'get_lessons'}, true); - ajax.get_lessons(section_id, section_position); -} - - - -/** - * Creates new lesson tr element - */ -add_new_lesson = function(event){ - - var section_id = jQuery(event.target).attr("data-section_id"); - - - if ( typeof( jQuery(event.target).attr("data-section") ) === undefined ) { - var section_position = 1; //default if no sectionid exists - } - else { - var section_position = jQuery(event.target).attr("data-section"); - } - - get_lessons(section_id, section_position); -} - - /** - * Generate lesson template - */ -lesson_template = function (lessons, section_id, section_position) { - - var row_id = (jQuery('#' + section_position + ' .list_item').length) + 1; - var select_class = 'list_item_' + section_position + '_' + row_id; - var row_class = 'row_' + section_position + '_' + row_id; - - var numRows = jQuery('#' + section_position + ' .dad-list').length; - - jQuery(' \ - ') - .appendTo('#' + section_position + ' .dad-list tbody').hide().fadeIn(300); - - jQuery(select).change(function() { update_syllabus(jQuery(select).val()); }); - jQuery('#' + section_position + ' .dad-list tbody ' + '.lesson-select').change(function() { get_edit_link(jQuery(this)); update_syllabus(); jQuery(this).attr('disabled', 'disabled'); }); - - jQuery('.deleteBtn').click(function() { - var contentPanelId = jQuery(this).attr("class"); - jQuery(this).parent().parent().remove(); - order_lessons(); - update_syllabus(); - }); - - - for (var key in lessons) { - - if (lessons.hasOwnProperty(key)) { - var select = jQuery('#' + section_position + ' #' + select_class); - var option = '' - jQuery(select).append(option); - //jQuery(select).prepend(''); - } - } - jQuery(select).prepend(''); -}; - -get_edit_link = function(element) { - console.log('get edit link called'); - console.log(element); - var lesson_id = jQuery(element).val(); - var element_id = jQuery(element).attr('id'); - console.log('element_id'); - console.log(element_id); - var type = jQuery(element).attr('data-type'); - - console.log(lesson_id); - var ajax = new Ajax('post', {'action':'get_lesson', 'lesson_id' : lesson_id}, true); - ajax.get_lesson(lesson_id, element_id, type); -} -add_edit_link = function(post, lesson_id, row_id, type) { - console.log('add_edit_link called'); - console.log(lesson_id); - console.log(post); - console.log(row_id); - console.log('type'); - console.log(type); - //var td = jQuery('#' + row_id).parent().next(); - - var edit_link = document.createElement('a'); - edit_link.setAttribute('href', encodeURI(post.edit_url)); - - var edit_icon = document.createElement('i'); - edit_icon.setAttribute('class', 'fa fa-pencil-square-o llms-fa-edit-lesson'); - - edit_link.appendChild(edit_icon); - // put components together to build section block - if (type == 'lesson') { - - jQuery('#' + row_id).parent().next().append(edit_link); - } - if (type == 'section') { - console.log('trying to append the emelemnt') - jQuery('#' + row_id).parent().append(edit_link); - } -} - - /** - * Generate lesson template - */ -associated_lesson_template = function (lessons, section_id, section_position) { - for (var key in lessons) { - - var row_id = (jQuery('#' + section_position + ' .list_item').length) + 1; - var select_class = 'list_item_' + section_position + '_' + row_id; - var row_class = 'row_' + section_position + '_' + row_id; - - var numRows = jQuery('#' + section_position + ' .dad-list').length; - - jQuery(' \ - \ - ') - .appendTo('#' + section_position + ' .dad-list tbody').hide().fadeIn(300); - - jQuery(select).change(function() { update_syllabus(jQuery(select).val()); }); - jQuery('#' + section_position + ' .dad-list tbody ' + '.lesson-select').change(function() { get_edit_link(jQuery(this)); update_syllabus(); jQuery(this).attr('disabled', 'disbaled'); }); - jQuery('.deleteBtn').click(function() { - var contentPanelId = jQuery(this).attr("class"); - jQuery(this).parent().parent().remove(); - order_lessons(); - update_syllabus(); - }); - - if (lessons.hasOwnProperty(key)) { - var select = jQuery('#' + section_position + ' #' + select_class); - - var option = '' - jQuery(select).append(option); - } - } -}; - -/** - * Deletes the grandparent of the delete button - */ -delete_this = function(thisButton){ - jQuery(thisButton).parent().parent().remove(); - - jQuery('.course-section').each( function(index) { - jQuery( this ).attr('id', index + 1 ) - jQuery( this ).find('label').text('Section ' + (index + 1) + ':'); - jQuery( this ).find('a.add-lesson').attr('data-section', index + 1); - - }); - order_lessons(); - update_syllabus(); -}; - -(function($){ - /** - * Create new section - */ - add_new_section = function () { - var ajax = new Ajax( 'post', { 'action' : 'get_sections' }, false ); - ajax.get_sections(); - } - - /** - * Generate section template - */ - section_template = function (sections) { - var response = sections; - - var id = $('.course-section').length + 1; - var sectionId = 'section_' + id; - - // create section wrapper - var section = document.createElement("div"); - section.setAttribute('class', 'course-section'); - section.setAttribute('id', id); - - // create title - var title = document.createElement('p'); - title.setAttribute('class', 'title'); - var label = document.createElement('label'); - label.setAttribute('class', 'order'); - $(label).text('Section ' + id + ':'); - - // create select list and add all options - var select = document.createElement('select'); - select.setAttribute('class', 'chosen-select chosen select section-select'); - select.setAttribute('data-placeholder', 'Select a Section'); - select.setAttribute('data-type', 'section'); - select.setAttribute('id', 'section_item_' + id); - - $(select).click(function() { reverse_selection ($(select))}); - $(select).change(function() { get_edit_link(jQuery(this)); catch_duplicates($(select)); $(this).attr('disabled', 'disbaled'); }); - $(select).attr("selectedIndex", -1); - - // create delete button - var removeBtn = document.createElement('i'); - removeBtn.setAttribute('data-code', 'f153'); - removeBtn.setAttribute('class', 'dashicons dashicons-dismiss section-dismiss'); - $(removeBtn).click(function() { delete_this($(select)) }); - - var moveBtn = document.createElement('i'); - moveBtn.setAttribute('class', 'fa fa-bars llms-fa-move-lesson'); - - // create add lesson button - var addLessonBtn = document.createElement('a'); - addLessonBtn.setAttribute('class', 'button button-primary add-lesson'); - - $('#' + sectionId).data( "section", { ID: id } ); - $(addLessonBtn).attr("data-section", id); - $(addLessonBtn).text('Add Lesson'); - //$(addLessonBtn).on('click', add_new_lesson()); - $(addLessonBtn).on('click', function(event){ add_new_lesson( event ) } ); - - // create table framework - var table = ' \ - \ - \ -
Name
Name
'; - - // populate select with sections. - $(select).append(''); - for (var key in response) { - if (response.hasOwnProperty(key)) { - var option = $('