diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..5b026c137 --- /dev/null +++ b/.gitignore @@ -0,0 +1,34 @@ +# Config +.relaxrc + +# Logs +logs +*.log + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +# Commenting this out is preferred by some people, see +# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- +node_modules + +# Users Environment Variables +.lock-wscript + +public/ +dist/ diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 000000000..9ad205f22 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,45 @@ +{ + "asi": false, + "bitwise": true, + "browser": false, + "curly": false, + "eqeqeq": true, + "eqnull": true, + "esnext": true, + "immed": true, + "latedef": false, + "newcap": false, + "noarg": true, + "nonew": true, + "quotmark": false, + "undef": true, + "unused": "vars", + "globalstrict": false, + "trailing": false, + "validthis": true, + "loopfunc": true, + "expr": true, + "globals": { + "Buffer": true, + "define": true, + "module": true, + "require": true, + "exports": true, + "describe": true, + "xdescribe": true, + "beforeEach": true, + "afterEach": true, + "it": true, + "xit": true, + "escape": true, + "process": true, + "__dirname": true, + "document": true, + "window": true, + "clearTimeout": true, + "setTimeout": true, + "clearInterval": true, + "setInterval": true, + "WebFont": true + } +} diff --git a/.npmignore b/.npmignore new file mode 100644 index 000000000..251af55af --- /dev/null +++ b/.npmignore @@ -0,0 +1,3 @@ +.relaxrc +lib/ +uploads/ diff --git a/.relaxrc.sample b/.relaxrc.sample new file mode 100644 index 000000000..4199e0e14 --- /dev/null +++ b/.relaxrc.sample @@ -0,0 +1,6 @@ +{ + "port": 8080, + "db": { + "uri": "mongodb://localhost/relax" + } +} diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 000000000..3d1c00ad7 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,150 @@ +module.exports = function (grunt) { + 'use strict'; + + var browserifyExternalOptions, browserifyExternalRequire; + + browserifyExternalOptions = browserifyExternalRequire = [ + 'backbone', + 'backbone-cortex', + 'jquery', + 'q', + 'react', + 'relax-framework' + ]; + + var browserifyProductionOptions = { + ignore: ['./lib/server/**/*'], + transform: [ + 'babelify' + ], + browserifyOptions: { + extensions: ['.jsx', '.js'] + }, + external: browserifyExternalOptions + }; + + grunt.initConfig({ + browserify: { + options: { + ignore: ['./lib/server/**/*'], + transform: [ + 'babelify' + ], + browserifyOptions: { + extensions: ['.jsx', '.js'], + debug: true + }, + external: browserifyExternalOptions, + watch: true + }, + common: { + options: { + ignore: ['./lib/server/**/*'], + transform: [ + 'babelify' + ], + browserifyOptions: { + extensions: ['.jsx', '.js'], + }, + require: browserifyExternalRequire, + external: null + }, + src: [], + dest: 'public/js/common.js' + }, + development: { + files: { + 'public/js/admin.js': ['lib/client/admin.js'], + 'public/js/auth.js': ['lib/client/auth.js'], + 'public/js/public.js': ['lib/client/public.js'] + } + }, + production: { + options: browserifyProductionOptions, + files: { + 'public/js/admin.js': ['lib/client/admin.js'], + 'public/js/auth.js': ['lib/client/auth.js'], + 'public/js/public.js': ['lib/client/public.js'] + } + } + }, + less: { + development: { + files: { + 'public/css/main.css': ['assets/less/main.less'] + } + }, + production: { + options: { + plugins: [ + new (require('less-plugin-autoprefix'))(), + new (require('less-plugin-clean-css'))() + ], + }, + files: { + 'public/css/main.css': ['assets/less/main.less'] + } + } + }, + uglify: { + production: { + files: { + 'public/js/common.js': ['public/js/common.js'], + 'public/js/admin.js': ['public/js/admin.js'], + 'public/js/auth.js': ['public/js/auth.js'], + 'public/js/public.js': ['public/js/public.js'] + } + } + }, + watch: { + options: { + interrupt: true, + livereload: false + }, + less: { + files: 'assets/**/*', + tasks: ['build:css:development'] + } + }, + nodemon: { + dev: { + script: 'index.js', + options: { + args: ['dev'], + env: { + 'NODE_ENV': 'development', + 'NODE_CONFIG': 'dev' + }, + nodeArgs: [], + ignore: ['node_modules/**'], + } + } + }, + concurrent: { + dev: { + tasks: ['nodemon', 'watch'], + options: { + logConcurrentOutput: true + } + } + } + }); + + grunt.loadNpmTasks('grunt-browserify'); + grunt.loadNpmTasks('grunt-contrib-copy'); + grunt.loadNpmTasks('grunt-contrib-less'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-contrib-watch'); + grunt.loadNpmTasks('grunt-concurrent'); + grunt.loadNpmTasks('grunt-nodemon'); + + grunt.registerTask('default', ['test', 'build']); + grunt.registerTask('build', ['build:development']); + grunt.registerTask('build:production', ['build:css:production', 'build:js:production']); + grunt.registerTask('build:development', ['build:css:development', 'build:js:development']); + grunt.registerTask('build:css:development', ['less:development']); + grunt.registerTask('build:css:production', ['less:production']); + grunt.registerTask('build:js:development', ['browserify:common', 'browserify:development']); + grunt.registerTask('build:js:production', ['browserify:common', 'browserify:production', 'uglify']); + grunt.registerTask('dev', ['build:development', 'concurrent:dev']); +}; diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..94a9ed024 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.md b/README.md new file mode 100644 index 000000000..7f31ea743 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +Relax CMS +========= diff --git a/app.js b/app.js new file mode 100644 index 000000000..e36b65f40 --- /dev/null +++ b/app.js @@ -0,0 +1,16 @@ +import app from './lib/server'; +import config from './config'; +import mongoose from 'mongoose'; +import logger from './lib/logger'; + +// Connect mongoose +if (!config.db) { + throw new Error('Configuration to MongoDB required'); +} +mongoose.connect(config.db.uri, config.db); + +// Start server +var server = app.listen(config.port, () => { + var port = server.address().port; + logger.debug('Listening at port', port); +}); diff --git a/assets/images/fonts-manager/fonts_icons.png b/assets/images/fonts-manager/fonts_icons.png new file mode 100644 index 000000000..5db064464 Binary files /dev/null and b/assets/images/fonts-manager/fonts_icons.png differ diff --git a/assets/less/boilerplate/main.less b/assets/less/boilerplate/main.less new file mode 100755 index 000000000..76e8071a6 --- /dev/null +++ b/assets/less/boilerplate/main.less @@ -0,0 +1,286 @@ +/*! HTML5 Boilerplate v5.0.0 | MIT License | http://h5bp.com/ */ + +/* + * What follows is the result of much research on cross-browser styling. + * Credit left inline and big thanks to Nicolas Gallagher, Jonathan Neal, + * Kroc Camen, and the H5BP dev community and team. + */ + +/* ========================================================================== + Base styles: opinionated defaults + ========================================================================== */ + +html { + color: #222; + font-size: 1em; + line-height: 1.4; +} + +body{ + overflow-x: hidden; +} + +/* + * Remove text-shadow in selection highlight: + * https://twitter.com/miketaylr/status/12228805301 + * + * These selection rule sets have to be separate. + * Customize the background color to match your design. + */ + +::-moz-selection { + background: #b3d4fc; + text-shadow: none; +} + +::selection { + background: #b3d4fc; + text-shadow: none; +} + +/* + * A better looking default horizontal rule + */ + +hr { + display: block; + height: 1px; + border: 0; + border-top: 1px solid #ccc; + margin: 1em 0; + padding: 0; +} + +/* + * Remove the gap between audio, canvas, iframes, + * images, videos and the bottom of their containers: + * https://github.com/h5bp/html5-boilerplate/issues/440 + */ + +audio, +canvas, +iframe, +img, +svg, +video { + vertical-align: middle; +} + +/* + * Remove default fieldset styles. + */ + +fieldset { + border: 0; + margin: 0; + padding: 0; +} + +/* + * Allow only vertical resizing of textareas. + */ + +textarea { + resize: vertical; +} + +/* ========================================================================== + Browser Upgrade Prompt + ========================================================================== */ + +.browserupgrade { + margin: 0.2em 0; + background: #ccc; + color: #000; + padding: 0.2em 0; +} + +/* ========================================================================== + Author's custom styles + ========================================================================== */ + + + + + + + + + + + + + + + + + +/* ========================================================================== + Helper classes + ========================================================================== */ + +/* + * Hide visually and from screen readers: + * http://juicystudio.com/article/screen-readers-display-none.php + */ + +.hidden { + display: none !important; + visibility: hidden; +} + +/* + * Hide only visually, but have it available for screen readers: + * http://snook.ca/archives/html_and_css/hiding-content-for-accessibility + */ + +.visuallyhidden { + border: 0; + clip: rect(0 0 0 0); + height: 1px; + margin: -1px; + overflow: hidden; + padding: 0; + position: absolute; + width: 1px; +} + +/* + * Extends the .visuallyhidden class to allow the element + * to be focusable when navigated to via the keyboard: + * https://www.drupal.org/node/897638 + */ + +.visuallyhidden.focusable:active, +.visuallyhidden.focusable:focus { + clip: auto; + height: auto; + margin: 0; + overflow: visible; + position: static; + width: auto; +} + +/* + * Hide visually and from screen readers, but maintain layout + */ + +.invisible { + visibility: hidden; +} + +/* + * Clearfix: contain floats + * + * For modern browsers + * 1. The space content is one way to avoid an Opera bug when the + * `contenteditable` attribute is included anywhere else in the document. + * Otherwise it causes space to appear at the top and bottom of elements + * that receive the `clearfix` class. + * 2. The use of `table` rather than `block` is only necessary if using + * `:before` to contain the top-margins of child elements. + */ + +.clearfix:before, +.clearfix:after { + content: " "; /* 1 */ + display: table; /* 2 */ +} + +.clearfix:after { + clear: both; +} + +/* ========================================================================== + EXAMPLE Media Queries for Responsive Design. + These examples override the primary ('mobile first') styles. + Modify as content requires. + ========================================================================== */ + +@media only screen and (min-width: 35em) { + /* Style adjustments for viewports that meet the condition */ +} + +@media print, + (-o-min-device-pixel-ratio: 5/4), + (-webkit-min-device-pixel-ratio: 1.25), + (min-resolution: 120dpi) { + /* Style adjustments for high resolution devices */ +} + +/* ========================================================================== + Print styles. + Inlined to avoid the additional HTTP request: + http://www.phpied.com/delay-loading-your-print-css/ + ========================================================================== */ + +@media print { + *, + *:before, + *:after { + background: transparent !important; + color: #000 !important; /* Black prints faster: + http://www.sanbeiji.com/archives/953 */ + box-shadow: none !important; + text-shadow: none !important; + } + + a, + a:visited { + text-decoration: underline; + } + + a[href]:after { + content: " (" attr(href) ")"; + } + + abbr[title]:after { + content: " (" attr(title) ")"; + } + + /* + * Don't show links that are fragment identifiers, + * or use the `javascript:` pseudo protocol + */ + + a[href^="#"]:after, + a[href^="javascript:"]:after { + content: ""; + } + + pre, + blockquote { + border: 1px solid #999; + page-break-inside: avoid; + } + + /* + * Printing Tables: + * http://css-discuss.incutio.com/wiki/Printing_Tables + */ + + thead { + display: table-header-group; + } + + tr, + img { + page-break-inside: avoid; + } + + img { + max-width: 100% !important; + } + + p, + h2, + h3 { + orphans: 3; + widows: 3; + } + + h2, + h3 { + page-break-after: avoid; + } +} diff --git a/assets/less/boilerplate/normalize.less b/assets/less/boilerplate/normalize.less new file mode 100755 index 000000000..69de7a632 --- /dev/null +++ b/assets/less/boilerplate/normalize.less @@ -0,0 +1,435 @@ +/*! normalize.css v3.0.2 | MIT License | git.io/normalize */ + +/** + * 1. Set default font family to sans-serif. + * 2. Prevent iOS text size adjust after orientation change, without disabling + * user zoom. + */ + +html { + font-family: sans-serif; /* 1 */ + -ms-text-size-adjust: 100%; /* 2 */ + -webkit-text-size-adjust: 100%; /* 2 */ +} + +iframe { + border: 0; +} + +/** + * Remove default margin. + */ + +body { + margin: 0; +} + +* { + box-sizing: border-box; +} + +/* HTML5 display definitions + ========================================================================== */ + +/** + * Correct `block` display not defined for any HTML5 element in IE 8/9. + * Correct `block` display not defined for `details` or `summary` in IE 10/11 + * and Firefox. + * Correct `block` display not defined for `main` in IE 11. + */ + +article, +aside, +details, +figcaption, +figure, +footer, +header, +hgroup, +main, +menu, +nav, +section, +summary { + display: block; +} + +/** + * 1. Correct `inline-block` display not defined in IE 8/9. + * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera. + */ + +audio, +canvas, +progress, +video { + display: inline-block; /* 1 */ + vertical-align: baseline; /* 2 */ +} + +/** + * Prevent modern browsers from displaying `audio` without controls. + * Remove excess height in iOS 5 devices. + */ + +audio:not([controls]) { + display: none; + height: 0; +} + +/** + * Address `[hidden]` styling not present in IE 8/9/10. + * Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22. + */ + +[hidden], +template { + display: none; +} + +/* Links + ========================================================================== */ + +/** + * Remove the gray background color from active links in IE 10. + */ + +a { + background-color: transparent; +} + +/** + * Improve readability when focused and also mouse hovered in all browsers. + */ + +a:active, +a:hover { + outline: 0; +} + +/* Text-level semantics + ========================================================================== */ + +/** + * Address styling not present in IE 8/9/10/11, Safari, and Chrome. + */ + +abbr[title] { + border-bottom: 1px dotted; +} + +/** + * Address style set to `bolder` in Firefox 4+, Safari, and Chrome. + */ + +b, +strong { + font-weight: bold; +} + +/** + * Address styling not present in Safari and Chrome. + */ + +dfn { + font-style: italic; +} + +/** + * Address variable `h1` font-size and margin within `section` and `article` + * contexts in Firefox 4+, Safari, and Chrome. + */ + +h1 { + font-size: 2em; + margin: 0.67em 0; +} + +/** + * Address styling not present in IE 8/9. + */ + +mark { + background: #ff0; + color: #000; +} + +/** + * Address inconsistent and variable font size in all browsers. + */ + +small { + font-size: 80%; +} + +/** + * Prevent `sub` and `sup` affecting `line-height` in all browsers. + */ + +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sup { + top: -0.5em; +} + +sub { + bottom: -0.25em; +} + +/* Embedded content + ========================================================================== */ + +/** + * Remove border when inside `a` element in IE 8/9/10. + */ + +img { + border: 0; +} + +/** + * Correct overflow not hidden in IE 9/10/11. + */ + +svg:not(:root) { + overflow: hidden; +} + +/* Grouping content + ========================================================================== */ + +/** + * Address margin not present in IE 8/9 and Safari. + */ + +figure { + margin: 1em 40px; +} + +/** + * Address differences between Firefox and other browsers. + */ + +hr { + -moz-box-sizing: content-box; + box-sizing: content-box; + height: 0; +} + +/** + * Contain overflow in all browsers. + */ + +pre { + overflow: auto; +} + +/** + * Address odd `em`-unit font size rendering in all browsers. + */ + +code, +kbd, +pre, +samp { + font-family: monospace, monospace; + font-size: 1em; +} + +/* Forms + ========================================================================== */ + +/** + * Known limitation: by default, Chrome and Safari on OS X allow very limited + * styling of `select`, unless a `border` property is set. + */ + +/** + * 1. Correct color not being inherited. + * Known issue: affects color of disabled elements. + * 2. Correct font properties not being inherited. + * 3. Address margins set differently in Firefox 4+, Safari, and Chrome. + */ + +button, +input, +optgroup, +select, +textarea { + color: inherit; /* 1 */ + font: inherit; /* 2 */ + margin: 0; /* 3 */ +} + +/** + * Address `overflow` set to `hidden` in IE 8/9/10/11. + */ + +button { + overflow: visible; +} + +/** + * Address inconsistent `text-transform` inheritance for `button` and `select`. + * All other form control elements do not inherit `text-transform` values. + * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera. + * Correct `select` style inheritance in Firefox. + */ + +button, +select { + text-transform: none; +} + +/** + * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` + * and `video` controls. + * 2. Correct inability to style clickable `input` types in iOS. + * 3. Improve usability and consistency of cursor style between image-type + * `input` and others. + */ + +button, +html input[type="button"], /* 1 */ +input[type="reset"], +input[type="submit"] { + -webkit-appearance: button; /* 2 */ + cursor: pointer; /* 3 */ +} + +/** + * Re-set default cursor for disabled elements. + */ + +button[disabled], +html input[disabled] { + cursor: default; +} + +/** + * Remove inner padding and border in Firefox 4+. + */ + +button::-moz-focus-inner, +input::-moz-focus-inner { + border: 0; + padding: 0; +} + +/** + * Address Firefox 4+ setting `line-height` on `input` using `!important` in + * the UA stylesheet. + */ + +input { + line-height: normal; +} + +/** + * It's recommended that you don't attempt to style these elements. + * Firefox's implementation doesn't respect box-sizing, padding, or width. + * + * 1. Address box sizing set to `content-box` in IE 8/9/10. + * 2. Remove excess padding in IE 8/9/10. + */ + +input[type="checkbox"], +input[type="radio"] { + box-sizing: border-box; /* 1 */ + padding: 0; /* 2 */ +} + +/** + * Fix the cursor style for Chrome's increment/decrement buttons. For certain + * `font-size` values of the `input`, it causes the cursor style of the + * decrement button to change from `default` to `text`. + */ + +input[type="number"]::-webkit-inner-spin-button, +input[type="number"]::-webkit-outer-spin-button { + height: auto; +} + +/** + * 1. Address `appearance` set to `searchfield` in Safari and Chrome. + * 2. Address `box-sizing` set to `border-box` in Safari and Chrome + * (include `-moz` to future-proof). + */ + +input[type="search"] { + -webkit-appearance: textfield; /* 1 */ + -moz-box-sizing: content-box; + -webkit-box-sizing: content-box; /* 2 */ + box-sizing: content-box; +} + +/** + * Remove inner padding and search cancel button in Safari and Chrome on OS X. + * Safari (but not Chrome) clips the cancel button when the search input has + * padding (and `textfield` appearance). + */ + +input[type="search"]::-webkit-search-cancel-button, +input[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} + +/** + * Define consistent border, margin, and padding. + */ + +fieldset { + border: 1px solid #c0c0c0; + margin: 0 2px; + padding: 0.35em 0.625em 0.75em; +} + +/** + * 1. Correct `color` not being inherited in IE 8/9/10/11. + * 2. Remove padding so people aren't caught out if they zero out fieldsets. + */ + +legend { + border: 0; /* 1 */ + padding: 0; /* 2 */ +} + +/** + * Remove default vertical scrollbar in IE 8/9/10/11. + */ + +textarea { + overflow: auto; +} + +/** + * Don't inherit the `font-weight` (applied by a rule above). + * NOTE: the default cannot safely be changed in Chrome and Safari on OS X. + */ + +optgroup { + font-weight: bold; +} + +/* Tables + ========================================================================== */ + +/** + * Remove most spacing between table cells. + */ + +table { + border-collapse: collapse; + border-spacing: 0; +} + +td, +th { + padding: 0; +} diff --git a/assets/less/components/admin/filter.less b/assets/less/components/admin/filter.less new file mode 100644 index 000000000..e025c456b --- /dev/null +++ b/assets/less/components/admin/filter.less @@ -0,0 +1,77 @@ +.filter-menu { + + padding: 20px 0px; + line-height: 25px; + border-bottom: 1px solid #dddddd; + margin-bottom: 20px; + background-color: #F5F5F5; + z-index: 1; + position: relative; + + .label-filter { + color: #626262; + font-size: 12px; + text-transform: uppercase; + display: inline-block; + vertical-align: top; + } + + .button-filter { + color: #626262; + font-size: 12px; + text-transform: uppercase; + display: inline-block; + vertical-align: top; + .opacity(0.7); + margin-right: 14px; + text-decoration: none; + .transition(); + + &:hover, &.active { + .opacity(1); + } + } + + form { + display: inline-block; + } + input { + display: inline-block; + margin-left: 30px; + border-radius: 19px; + border: 1px solid #ccc; + background-color: transparent; + line-height: 24px; + padding: 0 15px; + width: 170px; + font-size: 13px; + box-shadow: none; + outline: none; + color: #555555; + + &:focus { + border: 1px solid @adminPrimary; + background-color: #efefef; + } + } + + .filter-right { + display: inline-block; + float: right; + + a { + margin-right: 0; + margin-left: 20px; + } + } + + .alert { + .opacity(1); + color: @alert; + margin-left: 10px; + + &:hover { + color: @alertDarker; + } + } +} diff --git a/assets/less/components/admin/index.less b/assets/less/components/admin/index.less new file mode 100644 index 000000000..c7f4a013e --- /dev/null +++ b/assets/less/components/admin/index.less @@ -0,0 +1,241 @@ +@import './menu-bar.less'; +@import './top-menu/index.less'; +@import './filter.less'; +@import './init.less'; + +body{ + background-color: #f5f5f5; + font-family: 'Open Sans'; +} + +p { + color: #666; + font-size: 15px; +} + +.admin-holder { + position: absolute; + top: @pageBuilderTopMenuHeight; + left: 0; + bottom: 0; + right: 0; + background-color: #f5f5f5; + + .saving-info { + display: inline-block; + margin-left: 20px; + padding: 6px 0; + span { + line-height: 20px; + color: #555555; + padding-left: 10px; + font-size: 13px; + } + i { + line-height: 20px; + font-size: 18px; + color: @success; + } + >* { + display: inline-block; + vertical-align: top; + } + } + + .admin-content { + position: absolute; + left: @dashboardMenuWidth; + padding-right: 40px; + right: 0px; + top: 0; + bottom: 0; + } + .admin-scrollable { + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + padding-top: 66px; + padding-right: 40px; + overflow-y: auto; + overflow-x: hidden; + + &.with-footer { + padding-bottom: 50px; + } + } + .admin-title { + display: inline-block; + vertical-align: top; + line-height: 25px; + font-size: 16px; + color: #222; + } + .none-warning { + display: table; + width: 100%; + table-layout: fixed; + padding: 40px 30px; + + >* { + display: table-cell; + vertical-align: middle; + } + + .none-icon-part { + width: 60px; + i { + color: #999999; + font-size: 35px; + line-height: 40px; + } + } + .none-info-part { + p { + color: #999999; + font-size: 13px; + line-height: 25px; + margin: 0; + } + } + } + + .admin-footer { + position: absolute; + left: 0; + right: 40px; + bottom: 0; + padding: 12px 0px; + line-height: 25px; + border-top: 1px solid #dddddd; + background-color: #F5F5F5; + z-index: 1; + } + + .list { + padding: 30px 20px; + .entry { + display: table; + width: 100%; + table-layout: fixed; + margin-bottom: 25px; + + >* { + display: table-cell; + vertical-align: top; + } + + .icon-part { + width: 60px; + i { + color: @adminPrimary; + font-size: 35px; + line-height: 30px; + } + &.unpublished { + i { + color: #FD560C; + } + } + } + + .title { + display: inline-block; + vertical-align: top; + line-height: 30px; + font-size: 18px; + color: #333333; + } + .sub-title { + margin-left: 30px; + + i, span { + display: inline-block; + vertical-align: top; + line-height: 30px; + font-size: 11px; + color: #999999; + } + i { + font-size: 13px; + margin-right: 5px; + } + span { + text-transform: uppercase; + } + + &:hover { + i, span { + color: @adminPrimary; + } + } + } + + .under-title { + font-size: 13px; + color: #666666; + line-height: 20px; + text-transform: capitalize; + } + } + } + + .actions { + margin-top: 5px; + + a { + margin-right: 25px; + i, span { + display: inline-block; + vertical-align: top; + line-height: 30px; + font-size: 11px; + color: #999999; + } + i { + font-size: 15px; + margin-right: 5px; + } + span { + text-transform: uppercase; + } + + &:hover { + i, span { + color: @adminPrimary; + } + } + } + } + + .button-clean { + display: inline-block; + vertical-align: top; + text-decoration: none; + margin-left: 30px; + + span, i { + line-height: 25px; + color: #bbbbbb; + display: inline-block; + vertical-align: top; + } + span { + font-size: 11px; + text-transform: uppercase; + } + i { + font-size: 13px; + margin-right: 5px; + } + + &:hover, &.active { + span, i { + color: @adminPrimary; + } + } + } + + @import './panels/index.less'; +} diff --git a/assets/less/components/admin/init.less b/assets/less/components/admin/init.less new file mode 100644 index 000000000..1cf3e6817 --- /dev/null +++ b/assets/less/components/admin/init.less @@ -0,0 +1,14 @@ +.page-init { + position: absolute; + top: 45%; + left: 50%; + .transform(translate(-50%, -50%)); + max-width: 100%; + width: 480px; + h1 { + font-size: 50px; + line-height: 55px; + margin: 0; + margin-bottom: 30px; + } +} diff --git a/assets/less/components/admin/menu-bar.less b/assets/less/components/admin/menu-bar.less new file mode 100644 index 000000000..0ae111c83 --- /dev/null +++ b/assets/less/components/admin/menu-bar.less @@ -0,0 +1,135 @@ +.admin-menu-bar { + position: absolute; + + width: @dashboardMenuWidth; + top: 0; + bottom: 0; + left: 0; + + .top-info { + padding: 20px 20px; + padding-bottom: 0px; + i, span { + display: inline-block; + vertical-align: top; + line-height: 25px; + } + i { + font-size: 24px; + margin-right: 5px; + } + span { + font-size: 16px; + } + } + + .menu { + ul{ + list-style: none; + padding: 20px 0; + margin: 0; + + li{ + margin-bottom: 10px; + + a{ + display: block; + color: #8E8D8D; + text-decoration: none; + padding: 7px 20px; + font-size: 12px; + border-left: 10px solid transparent; + + &:hover, &.active { + color: #333333; + } + &.active { + border-color: @adminPrimary; + } + } + } + } + } + + .user-menu { + position: absolute; + bottom: 0; + left: 0; right: 0; + padding: 20px; + + >* { + display: inline-block; + vertical-align: top; + } + + .thumbnail { + width: 25px; + height: 25px; + .roundedCorners(3px); + overflow: hidden; + } + + span { + line-height: 25px; + padding-left: 10px; + font-size: 13px; + color: #444; + } + + .toggle-btn { + position: relative; + cursor: pointer; + float: right; + width: 25px; + height: 25px; + text-align: center; + .roundedCorners(3px); + + i { + font-size: 17px; + line-height: 24px; + color: #555; + } + + &:hover, &.active { + background-color: #dddddd; + } + + &.active { + .roundedCorners(0px, 0px, 3px, 3px); + } + + .toggle-menu { + position: absolute; + bottom: 25px; + right: 0; + width: 100px; + background-color: #dddddd; + text-align: left; + .roundedCorners(3px, 3px, 0px, 3px); + + a { + display: block; + text-decoration: none; + padding: 0 10px; + + i, span { + display: inline-block; + vertical-align: top; + font-size: 14px; + line-height: 28px; + color: #555; + } + span { + font-size: 10px; + text-transform: uppercase; + } + + &:hover { + background-color: #ccc; + } + } + } + } + } +} diff --git a/assets/less/components/admin/panels/colors.less b/assets/less/components/admin/panels/colors.less new file mode 100644 index 000000000..0f4feeec3 --- /dev/null +++ b/assets/less/components/admin/panels/colors.less @@ -0,0 +1,44 @@ +.color-manager { + + .color-manager-list { + padding: 30px 20px; + .color { + display: block; + margin-bottom: 20px; + .color-preview { + width: 65px; + height: 65px; + display: inline-block; + vertical-align: top; + } + .color-info { + display: inline-block; + vertical-align: top; + padding: 0 15px; + } + + .color-label { + color: #333333; + font-size: 15px; + text-transform: uppercase; + font-weight: 800; + } + .color-value { + color: #949494; + font-size: 11px; + } + .color-icon { + color: #333333; + display: inline-block; + visibility: hidden; + float: right; + line-height: 65px; + padding: 0 20px; + font-size: 20px; + .transform(translateX(-10px)); + } + + } + } + +} diff --git a/assets/less/components/admin/panels/fonts.less b/assets/less/components/admin/panels/fonts.less new file mode 100644 index 000000000..bfa281d62 --- /dev/null +++ b/assets/less/components/admin/panels/fonts.less @@ -0,0 +1,272 @@ +.fonts-manager-custom{ + .fonts-manager-custom-list{ + margin-bottom: 20px; + margin-top: 10px; + } + + .fonts-manager-custom-new-header{ + color: #333; + text-transform: uppercase; + padding: 12px 20px; + font-size: 12px; + border-bottom: 1px solid #cccccc; + } + + .fonts-manager-custom-new{ + position: relative; + padding: 20px 20px; + + >div{ + display: block; + } + .fonts-manager-custom-new-left{ + .option_main_holder{ + border-top: 0; + + &:last-child{ + padding-bottom: 20px; + } + } + .option_label{ + font-size: 13px; + margin: 0; + color: #333333; + line-height: 28px; + } + } + + .fonts-manager-custom-new-right{ + margin-top: 20px; + + .dropzone{ + position: relative; + + .dz-preview .dz-image{ + border-radius: 3px; + width: 80px; + height: 80px; + border: 1px solid #ccc; + background: #F5F3EE; + } + .dz-preview .dz-details{ + opacity: 1; + } + } + + + } + + .fonts-manager-custom-new-footer{ + display: block; + padding: 15px 0px; + margin-top: 15px; + + span{ + line-height: 20px; + font-size: 12px; + color: #DB2304; + margin-left: 20px; + } + + a{ + color: #999; + padding: 6px 11px; + border: 1px solid #999; + text-decoration: none; + border-radius: 3px; + + &:hover{ + color: @adminPrimary; + border-color: @adminPrimary; + } + } + } + } +} + +.list-font{ + position: relative; + display: inline-block; + width: 23%; + margin: 4px 1%; + margin-bottom: 10px; + box-sizing: border-box; + + .roundedCorners(3px); + + .font{ + color: #3d3d3d; + font-size: 60px; + line-height: 77px; + text-align: left; + white-space: nowrap; + padding-left: 7px 0; + overflow: hidden; + text-overflow: ellipsis; + } + .list-font-footer{ + padding: 7px 0; + + p{ + margin:0; + } + .list-font-family{ + font-size: 13px; + color: #00a3cf; + text-transform: capitalize; + } + .list-font-variation{ + font-size: 11px; + color: #404040; + } + } + .list-font-remove{ + text-align: center; + + position: absolute; + display: inline-block; + top: -9px; + right: -9px; + z-index: 1; + background-color: #DB2304; + width: 26px; + height: 26px; + border-radius: 13px; + + background-image: url(../images/ui/remove-icon-white.png); + background-position: 50% 50%; + background-repeat: no-repeat; + + &:hover{ + background-color: #333333; + } + } +} + +.tons-list-cover{ + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: #F9F9F9; + z-index:99; + .opacity(0.8); + + p{ + position: absolute; + top: 50%; + transform: translateY(-50%); + margin: 0 auto; + color: #111; + text-align: center; + font-size: 19px; + left: 0; + right: 0; + } +} + +.fonts-list{ + position: relative; + padding: 10px 7px; + + // List layout + &.fonts-list-layout-list{ + padding: 10px 13px; + .list-font{ + display: block; + margin: 0 0; + margin-bottom: 30px; + margin-top: 20px; + width: auto; + } + } +} + +.fonts-manager{ + *{ + box-sizing: border-box; + } + + // Menu + .fp-menu{ + position: relative; + + // Buttons + .fp-tab{ + display: inline-block; + padding: 14px 10px; + color: #4d4d4d; + border-bottom: 2px solid #db2304; + + width: 20%; + text-align: center; + box-sizing: border-box; + + font-size: 12px; + text-transform: uppercase; + + &:hover, &.active{ + background-color: #F7F7F7; + color: #333333; + } + &.validated{ + border-bottom: 2px solid #00c04a; + } + + span{ + display: inline-block; + line-height: 20px; + vertical-align: top; + } + + // Icon + .fp-tab-ic{ + display: inline-block; + width: 20px; + height: 20px; + margin-right: 13px; + overflow: hidden; + + background-image: url(../images/admin/fonts_icons.png); + background-repeat: no-repeat; + + &.fp-google{ + background-position: 0 0; + } + &.fp-typekit{ + background-position: 0 -20px; + } + &.fp-fontscom{ + background-position: 0 -40px; + } + &.fp-fontdeck{ + background-position: 0 -60px; + } + } + .fp-tab-icon{ + display: inline-block; + width: 20px; + text-align: center; + margin-right: 13px; + font-size: 18px; + line-height: 20px; + vertical-align: top; + color: #454545; + } + } + } + + // Options holder + .fp-options{ + position: relative; + padding: 47px 30px; + border-top: 0; + padding-bottom: 86px; + h2 { + font-size: 16px; + color: #333333; + } + } + +} diff --git a/assets/less/components/admin/panels/index.less b/assets/less/components/admin/panels/index.less new file mode 100644 index 000000000..313f0340b --- /dev/null +++ b/assets/less/components/admin/panels/index.less @@ -0,0 +1,6 @@ +@import './colors.less'; +@import './fonts.less'; +@import './media.less'; +@import './pages.less'; +@import './users.less'; +@import './schemas/index.less'; diff --git a/assets/less/components/admin/panels/media.less b/assets/less/components/admin/panels/media.less new file mode 100644 index 000000000..5e1bc72ad --- /dev/null +++ b/assets/less/components/admin/panels/media.less @@ -0,0 +1,134 @@ +.admin-media { + .list { + padding: 20px 10px; + .entry { + cursor: pointer; + display: inline-block; + width: 48%; + table-layout: fixed; + padding: 10px; + margin-right: 1%; + margin-bottom: 5px; + + >* { + display: table-cell; + vertical-align: top; + } + + .image-part { + width: 100px; + i { + color: @adminPrimary; + font-size: 35px; + line-height: 30px; + } + &.unpublished { + i { + color: #FD560C; + } + } + } + + .info-part { + padding-left: 20px; + } + + .title { + display: inline-block; + vertical-align: top; + line-height: 30px; + font-size: 15px; + color: #333333; + } + .sub-title { + margin-left: 30px; + + i, span { + display: inline-block; + vertical-align: top; + line-height: 30px; + font-size: 14px; + color: #999999; + } + i { + font-size: 17px; + margin-right: 5px; + } + + &:hover { + i, span { + color: @adminPrimary; + } + } + } + + .under-title { + font-size: 13px; + color: #666666; + line-height: 20px; + text-transform: capitalize; + } + + .actions { + margin-top: 5px; + + a { + margin-right: 25px; + i, span { + display: inline-block; + vertical-align: top; + line-height: 30px; + font-size: 11px; + color: #999999; + } + i { + font-size: 15px; + margin-right: 5px; + } + span { + text-transform: uppercase; + } + + &:hover { + i, span { + color: @adminPrimary; + } + } + } + } + + + &.active { + background-color: @adminPrimary; + .title{ + color: #ffffff; + } + .under-title { + color: #333333; + } + } + } + } +} + +.media-grid { + width: 100%; + clear: both; + margin-top: 20px; + a { + display: inline-block; + width: 24%; + height: 190px; + margin-right: 1%; + margin-bottom: 5px; + overflow: hidden; + background-position: 50% 50%; + background-size: cover; + border: 0px solid #10AE96; + .transition(0.1s); + + &.active { + border: 5px solid @adminPrimary; + } + } +} diff --git a/assets/less/components/admin/panels/pages.less b/assets/less/components/admin/panels/pages.less new file mode 100644 index 000000000..751079a17 --- /dev/null +++ b/assets/less/components/admin/panels/pages.less @@ -0,0 +1,3 @@ +.admin-pages { + +} diff --git a/assets/less/components/admin/panels/schemas/builder.less b/assets/less/components/admin/panels/schemas/builder.less new file mode 100644 index 000000000..2917e9c72 --- /dev/null +++ b/assets/less/components/admin/panels/schemas/builder.less @@ -0,0 +1,119 @@ +.schema-props-builder { + position: relative; + margin-top: 30px; + background-color: #FDFDFD; + + >div { + display: inline-block; + vertical-align: top; + } + + .info-label { + font-size: 16px; + color: #333333; + border-bottom: 1px solid #efefef; + padding: 12px 15px; + } + + .create { + width: 70%; + border-left: 1px solid #efefef; + + .create-holder { + padding: 25px 30px; + min-height: 225px; + } + } + + .added { + width: 30%; + + .prop-entry { + position: relative; + border-bottom: 1px solid #efefef; + border-radius: 2px; + padding: 10px 10px; + cursor: pointer; + + &:hover { + background-color: rgba(247, 247, 247, 0.31); + } + + &.active { + &:before { + content: ' '; + position: absolute; + left: 0; + top: 0; + bottom: 0; + width: 4px; + background-color: @adminPrimary; + } + } + + .remove-prop { + cursor: pointer; + position: absolute; + bottom: 0; + right: 0; + width: 30px; + height: 30px; + text-align: center; + i { + font-size: 18px; + line-height: 24px; + color: #cccccc; + } + &:hover { + i { + color: @alert; + } + } + } + .prop-info { + padding-left: 10px; + .prop-title { + font-size: 15px; + line-height: 20px; + color: #333333; + } + .prop-type { + font-size: 11px; + line-height: 16px; + color: #555555; + } + } + } + } + + .add-field-btn { + cursor: pointer; + height: 50px; + text-transform: uppercase; + text-decoration: none; + text-align: center; + + color: @adminPrimary; + + span, i { + display: inline-block; + vertical-align: top; + line-height: 50px; + font-size: 10px; + } + + i { + font-size: 14px; + position: relative; + margin-right: 10px; + } + + &:hover { + color: @adminPrimaryDarker; + } + } + + .none-warning { + + } +} diff --git a/assets/less/components/admin/panels/schemas/index.less b/assets/less/components/admin/panels/schemas/index.less new file mode 100644 index 000000000..8f0afd339 --- /dev/null +++ b/assets/less/components/admin/panels/schemas/index.less @@ -0,0 +1,5 @@ +@import './builder.less'; + +.admin-schemas { + +} diff --git a/assets/less/components/admin/panels/users.less b/assets/less/components/admin/panels/users.less new file mode 100644 index 000000000..9eaac0ec9 --- /dev/null +++ b/assets/less/components/admin/panels/users.less @@ -0,0 +1,30 @@ +.admin-users { + .list { + .entry { + display: inline-block; + vertical-align: top; + width: 33.32%; + + @media (max-width: 1150px) { + display: block; + width: 100%; + } + + .image-part { + display: table-cell; + vertical-align: top; + width: 90px; + + .img { + width: 70px; + height: 70px; + .roundedCorners(35px); + overflow: hidden; + } + } + .under-title { + text-transform: none; + } + } + } +} diff --git a/assets/less/components/admin/top-menu/add-overlay/entry.less b/assets/less/components/admin/top-menu/add-overlay/entry.less new file mode 100644 index 000000000..9906fa715 --- /dev/null +++ b/assets/less/components/admin/top-menu/add-overlay/entry.less @@ -0,0 +1,36 @@ +.entry { + display: block; + overflow: hidden; + text-decoration: none; + margin-bottom: 15px; + padding: 10px 18px; + + &:hover { + background-color: rgba(255, 255, 255, 0.1); + border-radius: 3px; + } + + >div { + display: table-cell; + vertical-align: middle; + } + + .icon-part { + i { + font-size: 30px; + color: @adminPrimary; + } + } + + .info-part { + padding-left: 20px; + .title { + color: #ffffff; + font-size: 16px; + } + .under-title { + color: #aaaaaa; + font-size: 12px; + } + } +} diff --git a/assets/less/components/admin/top-menu/add-overlay/index.less b/assets/less/components/admin/top-menu/add-overlay/index.less new file mode 100644 index 000000000..519eaa3d3 --- /dev/null +++ b/assets/less/components/admin/top-menu/add-overlay/index.less @@ -0,0 +1,35 @@ +.add-overlay { + @import './entry.less'; + + max-width: 1000px; + margin: 0 auto; + + >.title { + font-size: 18px; + color: #949494; + margin: 35px 0; + + span { + display: inline-block; + vertical-align: baseline; + } + + .sep { + margin: 0 8px; + } + + .active { + font-size: 24px; + color: #ffffff; + } + + .label:not(.active) { + cursor: pointer; + + &:hover { + color: #dddddd; + } + } + + } +} diff --git a/assets/less/components/admin/top-menu/index.less b/assets/less/components/admin/top-menu/index.less new file mode 100644 index 000000000..a8010d82f --- /dev/null +++ b/assets/less/components/admin/top-menu/index.less @@ -0,0 +1,215 @@ +@import './add-overlay/index.less'; + +.top-bar { + position: absolute; + left: 0px; right: 0; top: 0; + + height: @pageBuilderTopMenuHeight; + background-color: @pageBuilderTopMenu; + + z-index: 2; + -webkit-box-shadow: 0px 1px 3px 0px rgba(0,0,0,0.5); + -moz-box-shadow: 0px 1px 3px 0px rgba(0,0,0,0.5); + box-shadow: 0px 1px 3px 0px rgba(0,0,0,0.5); + + @tabsHeight: 25px; + @actionsHeight: 35px; + + .disabled { + .opacity(0.2); + &:after { + content: ' '; + .maxedSize(); + background-color: transparent; + } + } + + .page-actions { + height: @actionsHeight; + border-bottom: 1px solid #343333; + + .right-menu { + float: right; + position: relative; + } + } + + .tabs { + height: @tabsHeight; + .add-btn { + height: @tabsHeight; + display: inline-block; + vertical-align: top; + text-decoration: none; + color: #a5a4a4; + padding: 0 8px; + i { + font-size: 18px; + line-height: @tabsHeight; + } + &:hover{ + color: #ffffff; + } + } + .tab { + height: @tabsHeight; + border: 1px solid #343333; + border-bottom: 1px solid #343333; + border-top: 0; + display: inline-block; + vertical-align: top; + text-decoration: none; + color: #a5a4a4; + background-color: #292828; + + font-size: 13px; + line-height: @tabsHeight; + min-width: 200px; + + margin: 0 -1px; + padding: 0 12px; + + i { + vertical-align: top; + font-size: 18px; + line-height: @tabsHeight; + } + + &.fit { + i { + margin-right: 7px; + } + } + + .close { + float: right; + width: 16px; + height: 16px; + .roundedCorners(9px); + text-align: center; + position: relative; + top: 5px; + i { + font-size: 12px; + line-height: 16px; + vertical-align: top; + } + &:hover { + background-color: #DD6050; + } + } + + &.small { + min-width: 0; + } + + &.selected { + z-index: 1; + background-color: #191818; + color: #ffffff; + border-bottom: 1px solid #191818; + } + + &:hover{ + color: #ffffff; + } + } + } + + .center-menu { + @numberDisplays: 3; + position: absolute; + left: 0; + right: 0px; + height: @actionsHeight; + overflow: hidden; + + .top-bar-button i { + width: 35px; + } + .top-bar-button:nth-child(2) i { + font-size: 15px; + } + .top-bar-button:nth-child(3) i { + font-size: 13px; + } + + .center-menu-wraper { + position: absolute; + left: 50%; + width: @actionsHeight; + height: @actionsHeight; + overflow: hidden; + .transform(translateX(-(@actionsHeight / 2))); + .transition(0.2s); + + .center-menu-slider { + position: absolute; + top: 0; + left: 0; + width: @actionsHeight * @numberDisplays; + .transition(0.2s); + .transform(translateX(0)); + } + + &:hover { + width: @actionsHeight * @numberDisplays * 2; + @translate: @actionsHeight * @numberDisplays + @actionsHeight / 2; + .transform(translateX(-@translate)); + .center-menu-slider { + .transform(translateX(@actionsHeight * @numberDisplays)); + } + } + } + } + + + a.top-bar-button { + position: relative; + display: inline-block; + vertical-align: top; + line-height: @actionsHeight; + height: @actionsHeight; + text-align: center; + + text-transform: uppercase; + text-decoration: none; + font-size: 11px; + color: #a5a4a4; + + i { + width: 50px; + line-height: @actionsHeight; + font-size: 20px; + } + + &.text-button { + padding: 0 20px; + margin: 4px 5px; + line-height: @actionsHeight - 9; + height: @actionsHeight - 9; + } + + &.primary { + background-color: @adminPrimary; + color: #ffffff; + .roundedCorners(3px); + &:hover{ + background-color: @adminPrimaryDarker; + } + } + + &:hover, &.active { + color: @pageBuilderTopMenuTextActive; + } + } + + .seperator { + position: relative; + display: inline-block; + top: 8px; + width: 1px; + height: 16px; + background-color: #a5a4a4; + } +} diff --git a/assets/less/components/alert-box.less b/assets/less/components/alert-box.less new file mode 100644 index 000000000..e0329005f --- /dev/null +++ b/assets/less/components/alert-box.less @@ -0,0 +1,17 @@ +.alert-box { + padding: 10px 15px; + .roundedCorners(2px); + + &.warning { + color: #333; + border: 1px solid #FD560C; + font-size: 14px; + + a { + color: @adminPrimary; + } + } + &.success { + + } +} diff --git a/assets/less/components/border-picker.less b/assets/less/components/border-picker.less new file mode 100644 index 000000000..b9f160c1b --- /dev/null +++ b/assets/less/components/border-picker.less @@ -0,0 +1,96 @@ +.border-picker { + @btnsSize: 25px; + @btnsSpacing: 3px; + @total: @btnsSize * 3 + @btnsSpacing * 2; + + display: table; + width: 100%; + table-layout: fixed; + margin-top: 10px; + + // Parts + .toggles, .inputs { + display: table-cell; + vertical-align: middle; + } + + .toggles { + position: relative; + height: @total; + width: @total; + } + + .inputs { + padding-left: 25px; + padding-bottom: 13px; + + >* { + margin-bottom: 6px; + } + + .sub-label { + font-size: 9px; + color: #616363; + text-transform: uppercase; + margin-bottom: 5px; + } + } + + // Toggle buttons + .toggle { + position: absolute; + width: @btnsSize; + height: @btnsSize; + border: 1px solid #383838; + text-align: center; + cursor: pointer; + + i { + color: #cccccc; + font-size: 15px; + line-height: 23px; + } + + @center: @total / 2 - @btnsSize / 2; + + &.top { + left: @center; + top: 0; + } + &.left { + left: 0; + top: @center; + } + &.center { + left: @center; + top: @center; + } + &.right { + right: 0; + top: @center; + } + &.bottom { + left: @center; + top: 56px; + } + + &:hover { + background-color: #383838; + i { + color: #ffffff; + } + } + &.selected { + border-color: @adminPrimary; + background-color: #383838; + i { + color: #ffffff; + } + } + &.active { + i { + color: @adminPrimary; + } + } + } +} diff --git a/assets/less/components/border-style.less b/assets/less/components/border-style.less new file mode 100644 index 000000000..f0557b504 --- /dev/null +++ b/assets/less/components/border-style.less @@ -0,0 +1,68 @@ +.border-style { + @btnsSize: 25px; + @btnsSpacing: 3px; + + >* { + position: relative; + display: inline-block; + vertical-align: top; + width: @btnsSize; + height: @btnsSize; + margin-right: @btnsSpacing; + border: 1px solid #383838; + cursor: pointer; + text-align: center; + + i { + font-size: 14px; + line-height: @btnsSize; + color: #cccccc; + } + + &:after { + content: ' '; + position: absolute; + top: @btnsSize / 2 - 1px; + left: 3px; + right: 3px; + height: 0px; + border: 0; + } + + &.solid, &.dashed, &.dotted { + &:after { + border-bottom: 1px solid #cccccc; + } + } + &.dashed { + &:after { + border-style: dashed; + } + } + &.dotted { + &:after { + border-style: dotted; + } + } + + &:hover { + background-color: #383838; + i { + color: #ffffff; + } + &:after { + border-color: #ffffff; + } + } + + &.active { + border-color: @adminPrimary; + i { + color: @adminPrimary; + } + &:after { + border-color: @adminPrimary; + } + } + } +} diff --git a/assets/less/components/breadcrumbs.less b/assets/less/components/breadcrumbs.less new file mode 100644 index 000000000..5a98c7379 --- /dev/null +++ b/assets/less/components/breadcrumbs.less @@ -0,0 +1,29 @@ +.breadcrumbs { + display: inline-block; + vertical-align: top; + + span, a { + display: inline-block; + vertical-align: top; + line-height: 25px; + font-size: 16px; + color: #222; + } + + span { + color: #333333; + } + a { + color: @adminPrimary; + text-decoration: none; + + &:hover { + color: @adminPrimaryDarker; + } + } + i { + font-size: 15px; + padding: 0 10px; + color: #999999; + } +} diff --git a/assets/less/components/buttons.less b/assets/less/components/buttons.less new file mode 100644 index 000000000..683ecde1f --- /dev/null +++ b/assets/less/components/buttons.less @@ -0,0 +1,74 @@ +.button { + cursor: pointer; + padding: 8px 15px; + text-decoration: none; + font-size: 12px; + line-height: 15px; + display: inline-block; + vertical-align: top; + + .roundedCorners(3px); + + &.full { + display: block; + text-align: center; + margin-right: 0; + text-transform: uppercase; + font-size: 11px; + } + &.disabled { + .opacity(50); + pointer-events: none; + } + &.margined { + margin-left: 5px; + margin-right: 5px; + } + &.vmargined { + margin-top: 5px; + margin-bottom: 5px; + } +} + +.button-primary { + background-color: @adminPrimary; + color: #ffffff; + + &:hover { + background-color: @adminPrimaryDarker; + } +} + +.button-alert { + background-color: @alert; + color: #ffffff; + + &:hover { + background-color: @alertDarker; + } +} + +.button-grey { + background-color: #efefef; + color: #666666; + + &:hover { + color: @adminPrimaryDarker; + } +} + +.button-faded-grey { + background-color: rgba(239, 239, 239, 0.10); + color: #666666; + + &:hover { + color: @adminPrimaryDarker; + } +} + +.button-right { + margin-right: 0; + margin-left: 10px; + float: right; + clear: both; +} diff --git a/assets/less/components/checkbox.less b/assets/less/components/checkbox.less new file mode 100644 index 000000000..b992e78a9 --- /dev/null +++ b/assets/less/components/checkbox.less @@ -0,0 +1,39 @@ +.checkbox{ + position: relative; + display: inline-block; + width: 40px; + + .background{ + display: inline-block; + position: absolute; + background-color: #aaaaaa; + height: 10px; + left: 5px; + right: 5px; + margin-top: 6px; + .roundedCorners(8px); + .transition(); + } + + .circle{ + display: inline-block; + position: relative; + width: 20px; + height: 20px; + background-color: #ECECEC; + .transition(); + .roundedCorners(10px); + .drop-shadow-box(0, 1px, 1px, #aaaaaa, 100); + } + + // Active state + &.active{ + .circle{ + background-color: @adminPrimary; + .transform(translateX(100%)); + } + .background{ + background-color: @adminPrimaryLight; + } + } +} diff --git a/assets/less/components/color-palette-picker.less b/assets/less/components/color-palette-picker.less new file mode 100644 index 000000000..82748b93b --- /dev/null +++ b/assets/less/components/color-palette-picker.less @@ -0,0 +1,258 @@ +.color-picker { + @previewHeight: 35px; + + + .color-preview { + cursor: pointer; + border: 1px solid @adminPrimary; + position: relative; + height: @previewHeight; + line-height: @previewHeight; + padding: 0 7px; + background-color: @adminPrimary; + font-size: 11px; + font-weight: 800; + text-transform: uppercase; + color: #ffffff; + + &:before { + content: " "; + position: absolute; + background-image: url(../images/admin/dark-pattern.png); + background-repeat: repeat; + top: 0; right: 0; bottom: 0; left: 0; + z-index: -1; + } + + &:hover { + border-color: @adminPrimary !important; + } + + .expand { + position: absolute; + right: 0; top: 0; bottom: 0; + width: @previewHeight; + //border-left: 1px solid rgba(255, 255, 255, 0.3); + text-align: center; + i { + color: #ffffff; + line-height: @previewHeight; + text-align: center; + font-size: 18px; + } + } + } + + &.dark .color-preview { + color: #333333; + .expand i{ + color: #333333; + } + } + + .color-info { + border: 1px solid #383838; + border-top: 0; + height: @previewHeight; + display: block; + + >* { + display: table-cell; + vertical-align: top; + } + + .color-value-holder { + width: 65%; + padding: 8px 7px; + } + + .color-opacity-holder { + position: relative; + width: 35%; + text-align: right; + padding: 3px 0px; + + &:before { + content: ' '; + position: absolute; + left: 0; + top: 9px; + height: 16px; + width: 1px; + background-color: #383838; + } + } + + .color-value-preview { + width: 18px; + height: 18px; + background-color: #333333; + display: inline-block; + vertical-align: top; + margin-right: 5px; + border: 1px solid #383838; + cursor: pointer; + + &:hover { + border-color: @adminPrimary; + } + } + .color-value { + line-height: 20px; + color: #ffffff; + font-size: 12px; + display: inline-block; + vertical-align: top; + background-color: transparent; + border: 0; + outline: 0; + width: 70px; + } + } + + .number-input { + border: 0; + text-align: left; + .roundedCorners(0); + + input { + text-align: right; + } + + &.focused { + border: 0; + } + + .arrows a { + background-color: transparent; + &:last-child { + border-top: 0; + } + } + } + + .color-opened { + border: 1px solid #383838; + border-top: 0; + } + + .color-list { + @listItemHeight: 35px; + height: @listItemHeight * 4.5; + overflow-y: auto; + overflow-x: hidden; + + .color-entry { + cursor: pointer; + position: relative; + height: @listItemHeight; + line-height: @listItemHeight; + + >* { + display: inline-block; + vertical-align: top; + } + >span { + padding-left: 10px; + padding-right: 20px; + font-size: 12px; + color: #efefef; + } + + .color { + height: @listItemHeight; + width: 15px; + background-color: @adminPrimary; + } + .options-btn { + cursor: pointer; + visibility: hidden; + position: absolute; + right: 0; top: 0; bottom: 0; + width: @listItemHeight; + text-align: center; + >i { + font-size: 15px; + color: #616363; + line-height: @listItemHeight; + } + + &:hover { + >i { + color: #ffffff; + } + } + } + &:hover { + background-color: #12171a; + >span { + color: #ffffff; + } + .options-btn { + visibility: visible; + } + } + + &.selected { + background-color: #12171a; + >span { + color: @adminPrimary; + } + } + } + } + + .color-add-new { + border-top: 1px solid #383838; + height: 35px; + line-height: 35px; + text-align: center; + color: #616363; + cursor: pointer; + + i, span { + display: inline-block; + vertical-align: top; + color: #616363; + font-size: 14px; + line-height: 35px; + margin-right: 5px; + } + span { + font-size: 10px; + text-transform: uppercase; + } + + &:hover { + i, span { + color: #ffffff; + } + } + } + + .color-warning { + text-align: center; + padding: 42px 30px; + font-size: 12px; + color: #4D5252; + } + + &.small { + .color-info { + height: auto; + >* { + display: block; + } + .color-value-holder { + width: auto; + } + .color-opacity-holder { + width: auto; + text-align: left; + &:before { + content: none; + } + } + } + } +} diff --git a/assets/less/components/color-picker.less b/assets/less/components/color-picker.less new file mode 100644 index 000000000..66d7ebd83 --- /dev/null +++ b/assets/less/components/color-picker.less @@ -0,0 +1,227 @@ +/** + * RECOMMENDED STYLES + */ + +.abs (@top:auto, @left:auto, @bottom:@auto, @right:auto) { + display: block; + position: absolute; + top: @top; + bottom: @bottom; + left: @left; + right: @right; +} + +.color-picker-wrapper { + position: relative; + height: 350px; + margin: 30px 0; +} + +.colorpicker { + color: #333333; + .abs(0, 0, 0, 0); + + .map { + .abs(120px, 19px, 19px, 19px); + position: absolute; + user-select: none; + overflow: hidden; + + &.active { + cursor: none; + } + + &.dark .pointer { + border-color: #fff; + } + + &.light .pointer { + border-color: #000; + } + + .pointer { + position: absolute; + width: 10px; + height: 10px; + margin-left: -5px; + margin-top: -5px; + border-radius: 100%; + border: 1px solid #000; + } + + .background { + top: 0; + left: 0; + position: absolute; + height: 100%; + width: 100%; + } + + .background:before, + .background:after { + display: block; + content: ''; + position: absolute; + top: 0; + left: 0; + bottom: 0; + right: 0; + } + + .background:after { + background: linear-gradient(to bottom, ~'rgba(0,0,0,0)' 0%,~'rgba(0,0,0,1)' 100%); + } + + .background:before { + background: linear-gradient(to right, ~'rgba(255,255,255,1)' 0%,~'rgba(255,255,255,0)' 100%); + } + + } + + .slider { + position: absolute; + user-select: none; + + &.vertical { + top: 0; + bottom: 0; + left: 50%; + width: 10px; + cursor: ns-resize; + + .track { + position: absolute; + top: 0; + bottom: 0; + left: 50%; + width: 6px; + margin-left: -3px; + } + } + + &.horizontal { + left: 0; + right: 0; + top: 50%; + height: 10px; + cursor: ew-resize; + + .track { + position: absolute; + left: 0; + right: 0; + top: 50%; + height: 6px; + margin-top: -3px; + } + } + + .track { + border-radius: 3px; + background: #888; + } + + .pointer { + position: absolute; + bottom: 50%; + left: 50%; + width: 14px; + height: 14px; + background: #ddd; + margin-left: -7px; + margin-bottom: -7px; + border-radius: 14px; + } + + } + + .sat-slider { + .abs(auto, 19px, 12px, 19px); + } + + .light-slider { + .abs(120px, 2px, 18px, auto); + } + + .hue-slider { + .abs(120px, auto, 19px, 12px); + + .track { + background: linear-gradient(to bottom, + #FF0000 0%, + #FF0099 10%, + #CD00FF 20%, + #3200FF 30%, + #0066FF 40%, + #00FFFD 50%, + #00FF66 60%, + #35FF00 70%, + #CDFF00 80%, + #FF9900 90%, + #FF0000 100% + ); + } + + } + + .sample { + .abs(0, 0, auto, auto); + width: 100px; + height: 100px; + + .current { + height: 50%; + } + + .origin { + height: 50%; + } + } + + .details { + .abs(17px, 125px, auto, 19px); + + ul { + display: inline-block; + padding: 0; + margin: 0; + margin-right: 25px; + vertical-align: top; + + li { + list-style-type: none; + } + } + + label { + display: inline-block; + color: #888; + width: 15px; + margin-right: 5px; + text-align: right; + font-size: 13px; + font-weight: 800; + } + + input { + width: 55px; + text-transform: uppercase; + background: none; + border-radius: 3px; + border: none; + outline: none; + color: #666; + font-size: 13px; + font-weight: 400; + + &:focus { + color: #333; + } + } + + .rgb input, .hsv input { + width: 25px; + } + + } +} diff --git a/assets/less/components/columns-manager.less b/assets/less/components/columns-manager.less new file mode 100644 index 000000000..278da5339 --- /dev/null +++ b/assets/less/components/columns-manager.less @@ -0,0 +1,50 @@ +.columns-manager { + .columns-manager-options { + margin: 5px 0; + padding: 10px; + border-left: 2px solid @adminPrimary; + } + + .space { + height: 3px; + } + + .row { + display: table; + table-layout: fixed; + width: 100%; + + .column { + display: table-cell; + vertical-align: top; + } + } + + + .column { + position: relative; + cursor: pointer; + height: 22px; + + &:after { + content: " "; + position: absolute; + top: 2px; + right: 2px; + bottom: 2px; + left: 2px; + background-color: #333; + } + + &:hover { + &:after { + background-color: #ccc; + } + } + &.active { + &:after { + background-color: @adminPrimary; + } + } + } +} diff --git a/assets/less/components/combobox.less b/assets/less/components/combobox.less new file mode 100644 index 000000000..c21f606ab --- /dev/null +++ b/assets/less/components/combobox.less @@ -0,0 +1,131 @@ +.combobox{ + @comboboxHeight: 32px; + //min-width: 150px; + position: relative; + display: inline-block; + cursor: pointer; + width: 100%; + font-size: 13px; + + .combobox-holder{ + height: @comboboxHeight; + position: relative; + border: solid 1px #333333; + overflow: hidden; + //background-color: #383838; + + .roundedCorners (3px); + .transition(); + + .combobox-button{ + color: #efefef; + text-align: center; + i { + line-height: @comboboxHeight; + font-size: 13px; + } + } + + &.opened{ + height: auto; + } + } + + .combobox-header{ + overflow: hidden; + + .selected-text{ + position: relative; + padding: 0px 6px; + line-height: @comboboxHeight; + font-size: 13px; + display: inline-block; + float: left; + color: #efefef; + } + .combobox-button{ + display: inline-block; + float: right; + width: @comboboxHeight; + height: @comboboxHeight; + border-left: solid 1px #333333; + //background-color: #333333; + } + } + + .combobox-options-holder{ + position: relative; + left: 0; + display: block; + + border-top: solid 1px #333333; + } + + &:hover{ + .combobox-holder { + border-color: @adminPrimary; + } + .combobox-header { + .combobox-button { + background-color: #333333; + //border-color: @adminPrimary; + } + } + } +} + +.combobox-option{ + color: #858585; + //background-color: #383838; + padding: 6px 38px 6px 7px; + display: block; + font-size: 12px; + + .transition(0.2s); + + &:hover{ + background-color: @adminPrimary; + color: #ffffff; + } +} + +// White areas +.white-options { + .combobox{ + .combobox-holder{ + border-color: #cccccc; + color: #333333; + } + + .combobox-header { + .selected-text{ + color: #333333; + } + .combobox-button{ + color: #333333; + } + } + + .combobox-header .combobox-button { + border-color: #cccccc; + } + + .combobox-options-holder { + border-color: #cccccc; + } + + &:hover{ + .combobox-holder { + border-color: @adminPrimary; + .combobox-button { + color: #555555; + } + } + .combobox-header { + .combobox-button { + background-color: #efefef; + } + } + } + } +} diff --git a/assets/less/components/complement-menu.less b/assets/less/components/complement-menu.less new file mode 100644 index 000000000..da43627d6 --- /dev/null +++ b/assets/less/components/complement-menu.less @@ -0,0 +1,40 @@ +.complement-menu { + position: fixed; + z-index: 4; + + top: @pageBuilderTopMenuHeight + 100px + 65px; + right: 41px + @pageBuilderAdvancedMenuWidth; + width: @pageBuilderAdvancedMenuWidth; + height: 550px - 65px; + + background-color: @pageBuilderAdvancedMenu; + color: @pageBuilderChromeText; + + &:before { + content: " "; + position: absolute; + left: -1px; right: -1px; top: -1px; bottom: -1px; + -webkit-box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.82); + -moz-box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.82); + box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.82); + } + + .complement-content-scrollable { + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; + overflow-y: auto; + overflow-x: hidden; + } + + .complement-padded { + padding: 15px 10px; + } +} + +.advanced-menu.left .complement-menu { + right: auto; + left: 41px + @pageBuilderAdvancedMenuWidth; +} diff --git a/assets/less/components/corners-picker.less b/assets/less/components/corners-picker.less new file mode 100644 index 000000000..feed156eb --- /dev/null +++ b/assets/less/components/corners-picker.less @@ -0,0 +1,128 @@ +.corners-picker { + @btnsSize: 25px; + @btnsSpacing: 3px; + @total: @btnsSize * 3 + @btnsSpacing * 2; + + display: table; + width: 100%; + table-layout: fixed; + margin-top: 10px; + + // Parts + .toggles, .inputs { + display: table-cell; + vertical-align: middle; + } + + .toggles { + position: relative; + height: @total; + width: @total; + } + + .inputs { + padding-left: 25px; + padding-bottom: 13px; + + .sub-label { + font-size: 9px; + color: #616363; + text-transform: uppercase; + margin-bottom: 5px; + } + } + + // Toggle buttons + .toggle { + position: absolute; + width: @btnsSize; + height: @btnsSize; + border: 1px solid #383838; + text-align: center; + cursor: pointer; + + i { + color: #cccccc; + font-size: 15px; + line-height: 23px; + position: relative; + } + + @center: @total / 2 - @btnsSize / 2; + + span { + display: inline-block; + width: 10px; + height: 10px; + } + + &.tl { + left: 0; + top: 0; + span { + border-left: 2px solid #cccccc; + border-top: 2px solid #cccccc; + .roundedCorners(6px, 0, 0, 0); + } + } + &.tr { + right: 0; + top: 0; + span { + border-right: 2px solid #cccccc; + border-top: 2px solid #cccccc; + .roundedCorners(0, 6px, 0, 0); + } + } + &.center { + left: @center; + top: @center; + } + &.br { + right: 0; + bottom: 0; + span { + border-right: 2px solid #cccccc; + border-bottom: 2px solid #cccccc; + .roundedCorners(0, 0, 6px, 0); + } + } + &.bl { + left: 0; + bottom: 0; + span { + border-left: 2px solid #cccccc; + border-bottom: 2px solid #cccccc; + .roundedCorners(0, 0, 0, 6px); + } + } + + &:hover { + background-color: #383838; + i { + color: #ffffff; + } + span { + border-color: #ffffff; + } + } + &.selected { + border-color: @adminPrimary; + background-color: #383838; + i { + color: #ffffff; + } + span { + border-color: #ffffff; + } + } + &.active { + i { + color: @adminPrimary; + } + span { + border-color: @adminPrimary; + } + } + } +} diff --git a/assets/less/components/element.less b/assets/less/components/element.less new file mode 100644 index 000000000..b968a0635 --- /dev/null +++ b/assets/less/components/element.less @@ -0,0 +1,306 @@ +.element-highlight { + @borderSize: 1px; + position: absolute; + top: 0; left: 0; right: 0; bottom: 0; + pointer-events: none; + .border(@borderSize, solid, @pageBuilderElementHighlight, 80); + z-index: 2; + color: #ffffff; + + .element-identifier { + display: inline-block; + position: absolute; + top: -14px - @borderSize; left: 0 - @borderSize; + font-size: 11px; + line-height: 14px; + padding: 0px 3px; + + .roundedCorners(2px, 2px, 0, 0); + .alphaColorToRgb(@pageBuilderElementHighlight, 0.8); + + >* { + display: inline-block; + vertical-align: top; + } + i{ + margin-right: 3px; + font-size: 12px; + line-height: 14px; + color: #ffffff; + } + span { + line-height: 14px; + color: #ffffff; + } + } + + &.selected { + z-index: 1; + .border(@borderSize, solid, @pageBuilderElementSelected, 80); + + .element-identifier { + .alphaColorToRgb(@pageBuilderElementSelected, 0.8); + } + } + + &.bottom .element-identifier { + top: auto; + bottom: -16px; + .roundedCorners(0px, 0px, 2px, 2px); + } + + &.inside .element-identifier { + bottom: auto; + top: 2px; + left: 2px; + .roundedCorners(2px); + } + + &.sub-component { + .border(@borderSize, solid, @pageBuilderElementHighlightSub, 80); + + .element-identifier { + .alphaColorToRgb(@pageBuilderElementHighlightSub, 0.8); + } + + &.selected { + .border(@borderSize, solid, @pageBuilderElementSelectedSub, 80); + + .element-identifier { + .alphaColorToRgb(@pageBuilderElementSelectedSub, 0.8); + } + } + } +} + +.element-drop-highlight { + .maxedSize(); + pointer-events: none; + z-index: 2; + .opacity(0.4); + + &.horizontal { + border-left: 1px solid @pageBuilderElementDropHighlight; + border-right: 1px solid @pageBuilderElementDropHighlight; + } + &.vertical { + border-top: 1px solid @pageBuilderElementDropHighlight; + border-bottom: 1px solid @pageBuilderElementDropHighlight; + } +} + +.element-module-highlight { + .maxedSize(); + pointer-events: none; + z-index: 2; + .opacity(0.4); + .border(1px, dashed, #ff7700, 80); +} + +.dummy-placeholder { + background-color: #efefef; + height: 200px; + text-align: center; + max-height: 100%; + i { + font-size: 25px; + color: #333333; + top: 50%; + position: relative; + transform: translateY(-50%); + } +} + +.drop-placeholder { + position: relative; + text-align: center; + padding: 70px 30px; + color: #999999; + font-size: 14px; + + .link { + position: relative; + color: @adminPrimary; + display: inline-block; + + >span { + text-decoration: underline; + cursor: pointer; + } + + &:hover { + color: @adminPrimaryDarker; + } + } + + i { + font-size: 36px; + color: #999999; + } + + &:before { + content: ' '; + position: absolute; + top: 7px; + bottom: 7px; + left: 7px; + right: 7px; + border: 1px dashed #cccccc; + pointer-events: none; + } + + &.active { + &:before { + border: 1px solid @pageBuilderElementDropHighlight; + } + } +} + +.add-marker { + position: absolute; + width: 100%; + height: 0; + z-index: 3; + text-align: left; + + .marker { + position: absolute; + left: -35px; + top: -15px; + + width: 50px; + height: 30px; + + .opacity(0.90); + .transform(scale(0.6)); + .transition(0.3s); + } + + .circle { + width: 30px; + height: 30px; + background-color: #131618; + display: inline-block; + cursor: pointer; + position: relative; + text-align: center; + + .roundedCorners(15px); + + >i { + text-align: center; + color: #eeeeee; + font-size: 20px; + line-height: 30px; + } + } + + .triangle { + position: absolute; + background-color: #131618; + text-align: left; + cursor: pointer; + + position: absolute; + left: 16px; + top: 3px; + } + .triangle:before, + .triangle:after { + content: ''; + position: absolute; + background-color: inherit; + } + .triangle, + .triangle:before, + .triangle:after { + width: 16px; + height: 16px; + border-top-right-radius: 30%; + } + + .triangle { + transform: rotate(-90deg) skewX(-30deg) scale(1,.866); + } + .triangle:before { + transform: rotate(-135deg) skewX(-45deg) scale(1.414,.707) translate(0,-50%); + } + .triangle:after { + transform: rotate(135deg) skewY(-45deg) scale(.707,1.414) translate(50%); + } + + &:hover, &.active { + &:before { + content: ' '; + position: absolute; + display: block; + top: -1px; + bottom: -1px; + left: 0; right: 0; + background-color: @adminPrimary; + } + .marker { + .transform(scale(1)); + .opacity(1); + } + .circle, .triangle { + background-color: @adminPrimary; + + >i { + color: #ffffff; + } + } + } + + &.inverted { + .marker { + left: 14px; + .triangle { + transform: rotate(90deg) skewX(-30deg) scale(1,.866); + left: -2px; + top: 11px; + } + } + } + + &.vertical { + width: 0; + height: 100%; + + .triangle { + transform: rotate(-0deg) skewX(-30deg) scale(1,.866); + left: 11px; + top: 16px; + } + + .marker { + left: -15px; + top: -25px; + width: 30px; + height: 50px; + } + + &:hover { + &:before { + top: 0px; + bottom: 0px; + left: -1px; + right: -1px; + } + } + } +} + +.editing-wrapper { + position: relative; + + .editing-cover { + .maxedSize(); + background-color: rgba(255, 255, 255, 0); + .transition(); + } + + &:hover .editing-cover { + background-color: rgba(255, 255, 255, 0.2); + } +} diff --git a/assets/less/components/font-picker.less b/assets/less/components/font-picker.less new file mode 100644 index 000000000..d420f95c8 --- /dev/null +++ b/assets/less/components/font-picker.less @@ -0,0 +1,121 @@ +.font-picker{ + width: 100%; + border: 1px solid #333333; + + .roundedCorners(3px); + + // Font part + .font{ + color: #ffffff; + font-size: 60px; + line-height: 77px; + height: 77px; + text-align: center; + max-width: 100%; + border: 0; + box-shadow: none; + padding: 0; + margin: 0; + padding-left: 7px; + } + >p.warning{ + color: #fefefe; + line-height: 77px; + text-align: center; + margin:0; + } + + // Options + .font-picker-options{ + background-color: #383838; + padding: 5px 5px; + position: relative; + height: 40px; + + >div{ + position: relative; + display: inline-block; + margin: 0; + box-sizing: border-box; + text-decoration: none; + padding: 6px 8px; + vertical-align: top; + .roundedCorners(3px); + + z-index: 1; + + span{ + position: relative; + } + + i { + content: ""; + float: right; + width: 10px; + line-height: 21px; + position: relative; + } + + &:hover{ + background-color: #333333; + } + } + .font-picker-dropdown { + height: 30px; + font-size: 13px; + color: #ffffff; + >span{ + position: relative; + display: inline-block; + max-width: 125px; + width: 100%; + white-space: nowrap; + overflow: hidden !important; + text-overflow: ellipsis; + } + } + .font-picker-dropdown:first-child { + width: 67%; + margin-right:3%; + text-transform: capitalize; + } + .font-picker-dropdown:last-child { + width: 27%; + margin-left:3%; + } + .sep { + height: 24px; + width: 0; + border-left: 1px solid #333333; + position: absolute; + top: 8px; + } + + // Expand Menu + .collapsable { + position: absolute; + top: 0; left: 0; right: 0; + border: 1px solid #333333; + background-color: #333333; + padding-top: 29px; + margin-bottom: 30px; + + .roundedCorners(3px); + + a{ + font-size: 13px; + padding: 5px 7px; + color: #ccc; + + display: block; + text-decoration: none; + border-top: 1px solid #292929; + + &:hover{ + color: @adminPrimary; + background-color: #292929; + } + } + } + } +} diff --git a/assets/less/components/gemini-scrollbar.less b/assets/less/components/gemini-scrollbar.less new file mode 100644 index 000000000..2a9a654a4 --- /dev/null +++ b/assets/less/components/gemini-scrollbar.less @@ -0,0 +1,112 @@ +/** + * gemini-scrollbar + * @version 1.2.8 + * @link http://noeldelgado.github.io/gemini-scrollbar/ + * @license MIT + */ + +/* @helper: used to measure the scrollbar width on a temporal element */ +.gm-test { + width: 100px; + height: 100px; + position: absolute; + top: -9999px; + overflow: scroll; + -ms-overflow-style: scrollbar; +} + +/* disable selection while dragging */ +.gm-scrollbar-disable-selection { + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +/* fallback for native floating scrollbars */ +.gm-prevented { + -webkit-overflow-scrolling: touch; +} +.gm-prevented .gm-scrollbar { + display: none; +} + + +/* actual gemini-scrollbar styles */ +.gm-scrollbar-container { + position: relative; + overflow: hidden!important; + width: 100%; + height: 100%; +} + +.gm-scrollbar { + position: absolute; + right: 2px; + bottom: 2px; + z-index: 1; + border-radius: 3px; +} + +.gm-scrollbar.-vertical { + width: 5px; + top: 2px; +} + +.gm-scrollbar.-horizontal { + height: 6px; + left: 2px; +} + +.gm-scrollbar .thumb { + position: relative; + display: block; + width: 0; + height: 0; + cursor: pointer; + border-radius: inherit; + background-color: rgba(255, 255, 255, 0.1); +} + +.gm-scrollbar .thumb:hover, +.gm-scrollbar .thumb:active { + background-color: rgba(255, 255, 255, 0.3); +} + +.gm-scrollbar.-vertical .thumb { + width: 100%; +} + +.gm-scrollbar.-horizontal .thumb { + height: 100%; +} + +.gm-scrollbar-container .gm-scroll-view { + width: 100%; + height: 100%; + overflow: scroll; + -webkit-overflow-scrolling: touch; +} + +/* @option: autoshow */ +.gm-scrollbar-container.gm-autoshow .gm-scrollbar { + opacity: 0; + transition: opacity 120ms ease-out; +} +.gm-scrollbar-container.gm-autoshow:hover .gm-scrollbar, +.gm-scrollbar-container.gm-autoshow:focus .gm-scrollbar { + opacity: 1; + transition: opacity 340ms ease-out; +} + +.gm-scrollbar-black { + .gm-scrollbar .thumb { + background-color: rgba(0, 0, 0, 0.2); + } + .gm-scrollbar .thumb:hover, + .gm-scrollbar .thumb:active { + background-color: rgba(0, 0, 0, 0.4); + } +} diff --git a/assets/less/components/icon-manager.less b/assets/less/components/icon-manager.less new file mode 100644 index 000000000..b7c851ab3 --- /dev/null +++ b/assets/less/components/icon-manager.less @@ -0,0 +1,120 @@ +.icons-manager { + display: table; + width: 100%; + text-align: left; + + .tabs, .content { + display: table-cell; + vertical-align: top; + + .label { + margin: 0; + line-height: 60px; + color: #454545; + font-size: 12px; + font-weight: 600; + } + } + + .tabs { + width: 200px; + + .tab-button { + cursor: pointer; + font-size: 12px; + color: #656565; + + line-height: 28px; + padding: 5px 25px; + + border: 1px solid #dedede; + border-top-width: 0; + border-right-width: 0; + + &:first-child{ + border-top-width: 1px; + } + .number{ + color: #aaaaaa; + } + &:hover, &.active{ + background-color: #F1F1F1; + color: @adminPrimary; + + .number{ + color: @adminPrimary; + } + } + } + } + + .content { + .right { + float: right; + } + + input { + display: inline-block; + top: 14px; + position: relative; + border-radius: 17px; + outline: 0; + border: 1px solid #efefef; + line-height: 26px; + margin-left: 17px; + width: 200px; + padding: 0 10px; + font-size: 13px; + font-weight: 400; + + &:focus { + border-color: @adminPrimary; + } + } + + .icons { + border-top: 1px solid #dedede; + border-left: 1px solid #dedede; + } + + .icon { + cursor: pointer; + display: inline-block; + width: 16.65%; + height: 95px; + padding: 18px 10px 10px 10px; + border-right: 1px solid #dedede; + border-bottom: 1px solid #dedede; + position: relative; + + i{ + color: #454545; + display: block; + text-align: center; + font-size: 30px; + line-height: 30px; + } + p{ + display: block; + text-align: center; + font-size: 10px; + color: #999; + + display: block; + text-align: center; + left: 10px; + right: 10px; + font-size: 10px; + position: absolute; + bottom: 0; + } + + &:hover, &.active{ + background-color: @adminPrimary; + i, p{ + color: #ffffff; + } + } + } + } +} diff --git a/assets/less/components/icon-picker.less b/assets/less/components/icon-picker.less new file mode 100644 index 000000000..396de382c --- /dev/null +++ b/assets/less/components/icon-picker.less @@ -0,0 +1,81 @@ +.icon-picker { + @height: 60px; + + position: relative; + height: @height; + text-align: center; + background-color: #383838; + border: solid 1px #333333; + + .roundedCorners (3px); + .transition(); + + .selected { + height: @height; + line-height: @height; + font-size: 30px; + cursor: pointer; + } + + .icon-picker-opened { + position: absolute; + bottom: -1px; right: -1px; left: -1px; + height: 200px; + + background-color: #383838; + border: solid 1px @adminPrimary; + + .roundedCorners (3px); + + p { + margin: 0; + padding: 55px 22px; + font-size: 12px; + } + + .scrollable { + height: 163px; + overflow-y: auto; + text-align: left; + + .icon { + display: inline-block; + cursor: pointer; + width: 20%; + font-size: 16px; + border-right: 1px solid #333333; + border-bottom: 1px solid #333333; + line-height: 39px; + text-align: center; + color: #cccccc; + + &:hover, &.active { + background-color: @adminPrimary; + color: #ffffff; + } + } + } + .manage-icons { + display: block; + height: 35px; + text-align: center; + text-decoration: none; + color: #efefef; + border-top: 1px solid #333333; + line-height: 35px; + font-size: 12px; + + i { + font-size: 10px; + } + + &:hover { + background-color: #333333; + } + } + } + + &:hover { + border-color: @adminPrimary; + } +} diff --git a/assets/less/components/image-picker.less b/assets/less/components/image-picker.less new file mode 100644 index 000000000..2055be851 --- /dev/null +++ b/assets/less/components/image-picker.less @@ -0,0 +1,34 @@ +.image-picker { + display: inline-block; + + .image-selected{ + background-color: #cccccc; + position: relative; + overflow: hidden; + cursor: pointer; + width: 100%; + height: 100%; + + img { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + } + + .image-change { + background-color: rgba(0, 0, 0, 0.8); + .maxedSize(); + text-align: center; + padding: 50px 20px; + .opacity(0); + .transition(); + } + + &:hover .image-change { + .opacity(1); + } + } + + +} diff --git a/assets/less/components/index.less b/assets/less/components/index.less new file mode 100644 index 000000000..e8ad8474c --- /dev/null +++ b/assets/less/components/index.less @@ -0,0 +1,41 @@ +@import './input.less'; +@import './upload.less'; +@import './table.less'; +@import './checkbox.less'; +@import './combobox.less'; +@import './numeric-input.less'; +@import './input-validation.less'; +@import './lightbox.less'; +@import './image-picker.less'; +@import './media-selector.less'; +@import './color-picker.less'; +@import './color-palette-picker.less'; +@import './buttons.less'; +@import './breadcrumbs.less'; +@import './element.less'; +@import './options-menu.less'; +@import './options-list.less'; +@import './number-input.less'; +@import './style.less'; +@import './font-picker.less'; +@import './schema-link.less'; +@import './icon-picker.less'; +@import './icon-manager.less'; +@import './preview-style.less'; +@import './spacing-picker.less'; +@import './corners-picker.less'; +@import './complement-menu.less'; +@import './gemini-scrollbar.less'; +@import './alert-box.less'; +@import './spinner.less'; +@import './columns-manager.less'; +@import './border-picker.less'; +@import './border-style.less'; +@import './optional.less'; +@import './overlay.less'; + + +@import './page-builder/index.less'; +@import './admin/index.less'; +@import './style-picker/index.less'; +@import './medium-editor/index.less'; diff --git a/assets/less/components/input-validation.less b/assets/less/components/input-validation.less new file mode 100644 index 000000000..3d8f8009d --- /dev/null +++ b/assets/less/components/input-validation.less @@ -0,0 +1,27 @@ +.input-validate{ + position: relative; + + input{ + display: inline-block; + line-height: 30px; + width: 100%; + padding-right: 45px; + } + .input-valid{ + position: absolute; + top: 1px; + right: 1px; + + display: inline-block; + line-height: 36px; + padding: 0 13px; + color: #ffffff; + + &.valid{ + background-color: #9ec838; + } + &.invalid{ + background-color: #f13237; + } + } +} diff --git a/assets/less/components/input.less b/assets/less/components/input.less new file mode 100644 index 000000000..401dc9aff --- /dev/null +++ b/assets/less/components/input.less @@ -0,0 +1,57 @@ +.input { + .roundedCorners(2px); + max-width: 480px; + + input { + border: 0; + background: transparent; + box-shadow: none; + width: 100%; + display: block; + outline: none; + border: 1px solid #383838; + border-radius: 3px; + padding: 7px 7px; + font-size: 13px; + .transition(); + + &:focus { + border-color: @adminPrimary; + } + } + + &.big { + input { + font-size: 17px; + } + } + + &.white { + input { + border-color: #cccccc; + color: #333333; + } + } +} + +input.valid { + border: 1px solid #00ff00; +} + +input.invalid { + border: 1px solid #ff0000; +} + +// White areas +.white-options { + .input { + input { + border-color: #cccccc; + color: #333333; + + &:focus { + border-color: @adminPrimary; + } + } + } +} diff --git a/assets/less/components/lightbox.less b/assets/less/components/lightbox.less new file mode 100644 index 000000000..fc5000922 --- /dev/null +++ b/assets/less/components/lightbox.less @@ -0,0 +1,96 @@ +.lightbox { + position: fixed; + top: 0; left: 0; right: 0; bottom: 0; + + overflow-y: auto; + overflow-x: hidden; + z-index: 99; + + .lightbox-background { + position: fixed; + top: 0; left: 0; right: 0; bottom: 0; + opacity: 0; + background-color: rgba(0, 0, 0, 0.4); + } + + .animation-holder { + opacity: 0; + } + + .lightbox-wrapper { + position: relative; + background-color: #ffffff; + width: 80%; + + margin: 30px auto; + .roundedCorners(3px); + } + + &.small { + overflow: hidden; + .animation-holder { + position: absolute; + top: 0; left: 0; right: 0; bottom: 0; + } + .lightbox-wrapper { + position: absolute; + width: 500px; + max-width:100%; + top: 40%; + left: 50%; + .transform(translate(-50%, -50%)); + } + } + + .lightbox-header { + @height: 55px; + height: @height; + border-bottom: 1px solid #E2E2E2; + + .lightbox-title{ + float: left; + margin: 0; + line-height: @height; + padding-left: 20px; + color: #333; + } + + .lightbox-close { + display: inline-block; + height: @height; + width: @height; + + float: right; + color: #333333; + + text-align: center; + line-height: 50px; + + &:hover{ + color: @adminPrimary; + } + } + } + + .lightbox-content { + padding: 30px; + } + + .big { + font-size: 19px; + color: #333; + } + + .medium { + font-size: 15px; + color: #555; + } + + .space-above { + margin-top: 25px; + } + + .centered { + text-align: center; + } +} diff --git a/assets/less/components/media-selector.less b/assets/less/components/media-selector.less new file mode 100644 index 000000000..dee750879 --- /dev/null +++ b/assets/less/components/media-selector.less @@ -0,0 +1,34 @@ +.media-selector { + .ms-item { + padding: 5px; + border: 3px solid #ffffff; + display: inline-block; + + &.selected { + border-color: @adminPrimary; + } + } + + .dropzone { + border: 0; + padding: 0; + } + + .dz-image-preview{ + margin: 0 !important; + } + + .dropzone .dz-preview .dz-image{ + width: 100px; + height: 100px; + border-radius: 0; + + padding: 5px; + border: 3px solid #ffffff; + display: inline-block; + } + + .dropzone .dz-message { + color: #999999; + } +} diff --git a/assets/less/components/medium-editor/base.less b/assets/less/components/medium-editor/base.less new file mode 100644 index 000000000..91db3731a --- /dev/null +++ b/assets/less/components/medium-editor/base.less @@ -0,0 +1,211 @@ +@-webkit-keyframes medium-editor-image-loading { + 0% { + -webkit-transform: scale(0); + transform: scale(0); } + 100% { + -webkit-transform: scale(1); + transform: scale(1); } } + +@keyframes medium-editor-image-loading { + 0% { + -webkit-transform: scale(0); + transform: scale(0); } + 100% { + -webkit-transform: scale(1); + transform: scale(1); } } + +@-webkit-keyframes medium-editor-pop-upwards { + 0% { + opacity: 0; + -webkit-transform: matrix(0.97, 0, 0, 1, 0, 12); + transform: matrix(0.97, 0, 0, 1, 0, 12); } + 20% { + opacity: .7; + -webkit-transform: matrix(0.99, 0, 0, 1, 0, 2); + transform: matrix(0.99, 0, 0, 1, 0, 2); } + 40% { + opacity: 1; + -webkit-transform: matrix(1, 0, 0, 1, 0, -1); + transform: matrix(1, 0, 0, 1, 0, -1); } + 100% { + -webkit-transform: matrix(1, 0, 0, 1, 0, 0); + transform: matrix(1, 0, 0, 1, 0, 0); } } + +@keyframes medium-editor-pop-upwards { + 0% { + opacity: 0; + -webkit-transform: matrix(0.97, 0, 0, 1, 0, 12); + transform: matrix(0.97, 0, 0, 1, 0, 12); } + 20% { + opacity: .7; + -webkit-transform: matrix(0.99, 0, 0, 1, 0, 2); + transform: matrix(0.99, 0, 0, 1, 0, 2); } + 40% { + opacity: 1; + -webkit-transform: matrix(1, 0, 0, 1, 0, -1); + transform: matrix(1, 0, 0, 1, 0, -1); } + 100% { + -webkit-transform: matrix(1, 0, 0, 1, 0, 0); + transform: matrix(1, 0, 0, 1, 0, 0); } } + +.medium-editor-anchor-preview { + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 16px; + left: 0; + line-height: 1.4; + max-width: 280px; + position: absolute; + text-align: center; + top: 0; + word-break: break-all; + word-wrap: break-word; + visibility: hidden; + z-index: 2000; } + .medium-editor-anchor-preview a { + color: #fff; + display: inline-block; + margin: 5px 5px 10px; } + +.medium-editor-anchor-preview-active { + visibility: visible; } + +.medium-editor-dragover { + background: #ddd; } + +.medium-editor-image-loading { + -webkit-animation: medium-editor-image-loading 1s infinite ease-in-out; + animation: medium-editor-image-loading 1s infinite ease-in-out; + background-color: #333; + border-radius: 100%; + display: inline-block; + height: 40px; + width: 40px; } + +.medium-editor-placeholder { + position: relative; } + .medium-editor-placeholder:after { + content: attr(data-placeholder) !important; + font-style: italic; + left: 0; + position: absolute; + top: 0; + white-space: pre; } + +.medium-toolbar-arrow-under:after, .medium-toolbar-arrow-over:before { + border-style: solid; + content: ''; + display: block; + height: 0; + left: 50%; + margin-left: -8px; + position: absolute; + width: 0; } + +.medium-toolbar-arrow-under:after { + border-width: 8px 8px 0 8px; } + +.medium-toolbar-arrow-over:before { + border-width: 0 8px 8px 8px; + top: -8px; } + +.medium-editor-toolbar { + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 16px; + left: 0; + position: absolute; + top: 0; + visibility: hidden; + z-index: 2000; } + .medium-editor-toolbar ul { + margin: 0; + padding: 0; } + .medium-editor-toolbar li { + float: left; + list-style: none; + margin: 0; + padding: 0; } + .medium-editor-toolbar li button { + box-sizing: border-box; + cursor: pointer; + display: block; + font-size: 14px; + line-height: 1.33; + margin: 0; + padding: 15px; + text-decoration: none; } + .medium-editor-toolbar li button:focus { + outline: none; } + .medium-editor-toolbar li .medium-editor-action-underline { + text-decoration: underline; } + .medium-editor-toolbar li .medium-editor-action-pre { + font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; + font-size: 12px; + font-weight: 100; + padding: 15px 0; } + +.medium-editor-toolbar-active { + visibility: visible; } + +.medium-editor-sticky-toolbar { + position: fixed; + top: 1px; } + +.medium-editor-toolbar-active.medium-editor-stalker-toolbar { + -webkit-animation: medium-editor-pop-upwards 160ms forwards linear; + animation: medium-editor-pop-upwards 160ms forwards linear; } + +.medium-editor-action-bold { + font-weight: bolder; } + +.medium-editor-action-italic { + font-style: italic; } + +.medium-editor-toolbar-form { + display: none; } + .medium-editor-toolbar-form input, + .medium-editor-toolbar-form a { + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; } + .medium-editor-toolbar-form .medium-editor-toolbar-form-row { + line-height: 14px; + margin-left: 5px; + padding-bottom: 5px; } + .medium-editor-toolbar-form .medium-editor-toolbar-input, + .medium-editor-toolbar-form label { + border: none; + box-sizing: border-box; + font-size: 14px; + margin: 0; + padding: 6px; + width: 316px; + display: inline-block; } + .medium-editor-toolbar-form .medium-editor-toolbar-input:focus, + .medium-editor-toolbar-form label:focus { + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; + border: none; + box-shadow: none; + outline: 0; } + .medium-editor-toolbar-form a { + display: inline-block; + font-size: 24px; + font-weight: bolder; + margin: 0 10px; + text-decoration: none; } + +.medium-editor-toolbar-actions:after { + clear: both; + content: ""; + display: table; } + +[data-medium-editor-element] img { + max-width: 100%; } + +[data-medium-editor-element] sub { + vertical-align: sub; } + +[data-medium-editor-element] sup { + vertical-align: super; } + +.medium-editor-hidden { + display: none; } diff --git a/assets/less/components/medium-editor/index.less b/assets/less/components/medium-editor/index.less new file mode 100644 index 000000000..596989f7d --- /dev/null +++ b/assets/less/components/medium-editor/index.less @@ -0,0 +1,2 @@ +@import './base.less'; +@import './theme.less'; diff --git a/assets/less/components/medium-editor/theme.less b/assets/less/components/medium-editor/theme.less new file mode 100644 index 000000000..2f4eb4038 --- /dev/null +++ b/assets/less/components/medium-editor/theme.less @@ -0,0 +1,95 @@ +.medium-toolbar-arrow-under:after { + border-color: rgba(19, 22, 24, 0.95) transparent transparent transparent; + top: 40px; +} + +.medium-toolbar-arrow-over:before { + border-color: transparent transparent rgba(19, 22, 24, 0.95) transparent; +} + +.medium-editor-toolbar { + background-color: rgba(19, 22, 24, 0.95); + border-radius: 4px; +} +.medium-editor-toolbar li button { + background-color: transparent; + border: none; + border-right: 1px solid rgba(0, 0, 0, 0.2); + box-sizing: border-box; + color: #efefef; + height: 40px; + min-width: 40px; + padding: 0; + -webkit-transition: background-color 0.2s ease-in, color 0.2s ease-in; + transition: background-color 0.2s ease-in, color 0.2s ease-in; +} +.medium-editor-toolbar li button:hover { + background-color: #12171a; + color: #fff; +} +.medium-editor-toolbar li .medium-editor-button-first { + border-bottom-left-radius: 4px; + border-top-left-radius: 4px; +} +.medium-editor-toolbar li .medium-editor-button-last { + border-bottom-right-radius: 4px; + border-right: none; + border-top-right-radius: 4px; +} + +.medium-editor-toolbar li .medium-editor-button-active { + position: relative; + color: #fff; +} +.medium-editor-toolbar li .medium-editor-button-active { + &:after { + content: " "; + position: absolute; + left: 0; right: 0; bottom: 0; + height: 3px; + background-color: @adminPrimary; + } +} + +.medium-editor-toolbar-form { + background: transparent; + border-radius: 4px; + color: #fff; +} +.medium-editor-toolbar-form .medium-editor-toolbar-input { + background: transparent; + color: #fff; + height: 40px; +} +.medium-editor-toolbar-form .medium-editor-toolbar-input::-webkit-input-placeholder { + color: #fff; + color: rgba(255, 255, 255, 0.8); +} +.medium-editor-toolbar-form .medium-editor-toolbar-input:-moz-placeholder { + /* Firefox 18- */ + color: #fff; + color: rgba(255, 255, 255, 0.8); +} +.medium-editor-toolbar-form .medium-editor-toolbar-input::-moz-placeholder { + /* Firefox 19+ */ + color: #fff; + color: rgba(255, 255, 255, 0.8); +} +.medium-editor-toolbar-form .medium-editor-toolbar-input:-ms-input-placeholder { + color: #fff; + color: rgba(255, 255, 255, 0.8); +} +.medium-editor-toolbar-form a { + color: #fff; + font-size: 14px; +} + +.medium-editor-toolbar-anchor-preview { + background: rgba(19, 22, 24, 0.95); + border-radius: 4px; + color: #fff; +} + +.medium-editor-placeholder:after { + color: rgba(19, 22, 24, 0.95); +} diff --git a/assets/less/components/number-input.less b/assets/less/components/number-input.less new file mode 100644 index 000000000..6a18e7d2a --- /dev/null +++ b/assets/less/components/number-input.less @@ -0,0 +1,75 @@ +.number-input { + width: 90px; + height: 30px; + display: block; + position: relative; + outline: none; + //background-color: #12171A; + border: 1px solid #383838; + border-radius: 3px; + overflow: hidden; + .transition(); + + &.focused { + border: 1px solid @adminPrimary; + } + + input { + display: inline-block; + vertical-align: top; + border: 0; + outline: 0; + background: transparent; + box-shadow: none; + line-height: 30px; + padding: 0 5px; + width: 40px; + font-size: 12px; + } + + span { + display: inline-block; + vertical-align: top; + line-height: 30px; + width: 30px; + font-size: 12px; + text-align: center; + color: #858585; + cursor: ns-resize; + } + + .arrows { + display: inline-block; + vertical-align: top; + position: absolute; + width: 20px; + top: 0; + right: 0; + bottom: 0; + a { + background-color: #383838; + color: #efefef; + position: absolute; + top: 0; + left: 0; + right: 0; + height: 15px; + text-align: center; + font-size: 11px; + + i { + line-height: 15px; + } + + &:last-child { + top: auto; + bottom: 0; + border-top: 1px solid #333333; + } + + &:hover { + background-color: @adminPrimary; + } + } + } +} diff --git a/assets/less/components/numeric-input.less b/assets/less/components/numeric-input.less new file mode 100644 index 000000000..56f50dd59 --- /dev/null +++ b/assets/less/components/numeric-input.less @@ -0,0 +1,66 @@ +.numeric { + position: relative; + display: table; + table-layout: fixed; + width: 100%; + + .numeric-slider { + position: relative; + display: table-cell; + vertical-align: middle; + font-size: 0; + + .background { + display: inline-block; + position: absolute; + background-color: #aaaaaa; + cursor: pointer; + height: 10px; + left: 5px; + right: 5px; + margin-top: 6px; + .roundedCorners(8px); + .transition(); + + .background-active { + height: 10px; + width: 0; + background-color: @adminPrimary; + display: block; + .roundedCorners(8px); + } + } + + .circle { + display: inline-block; + position: relative; + cursor: ew-resize; + width: 20px; + height: 20px; + background-color: #ECECEC; + .roundedCorners(10px); + .drop-shadow-box(0, 1px, 1px, #aaaaaa, 100); + } + } + + .input-holder { + display: table-cell; + vertical-align: middle; + width: 70px; + padding-left: 10px; + + input{ + display: inline-block; + padding: 3px 7px; + width: 40px; + font-size: 13px; + text-align: center; + } + label{ + font-size: 13px; + display: inline-block; + width: 20px; + text-align: center; + } + } +} diff --git a/assets/less/components/optional.less b/assets/less/components/optional.less new file mode 100644 index 000000000..4a87c8c33 --- /dev/null +++ b/assets/less/components/optional.less @@ -0,0 +1,48 @@ +.optional { + @size: 15px; + position: relative; + cursor: pointer; + padding: 0 3px; + + .box, .label { + vertical-align: top; + line-height: 17px; + .transition(); + } + + .label { + margin: 0; + padding: 0; + padding-right: @size + 5px; + } + + .box { + position: absolute; + right: 3px; + top: 1px; + display: inline-block; + width: @size; + height: @size; + text-align: center; + border: 1px solid #383838; + .roundedCorners(3px); + + i { + font-size: 23px; + color: @adminPrimary; + top: -2px; + left: -4px; + position: relative; + line-height: 15px; + } + } + + &:hover { + .label { + color: #efefef; + } + .box { + border-color: #777; + } + } +} diff --git a/assets/less/components/options-list.less b/assets/less/components/options-list.less new file mode 100644 index 000000000..8ff314da2 --- /dev/null +++ b/assets/less/components/options-list.less @@ -0,0 +1,28 @@ +.option { + margin-bottom: 35px; + .label { + text-transform: uppercase; + font-size: 11px; + font-weight: 800; + color: #9B9B9B; + line-height: 16px; + margin-bottom: 10px; + padding: 0 3px; + + >* { + display: inline-block; + vertical-align: top; + line-height: 16px; + } + i { + margin-right: 7px; + font-size: 14px; + } + } + >.options-group { + padding-left: 10px; + padding-top: 10px; + border-left: 1px solid #999; + margin-left: 10px; + } +} diff --git a/assets/less/components/options-menu.less b/assets/less/components/options-menu.less new file mode 100644 index 000000000..ea48d2fa1 --- /dev/null +++ b/assets/less/components/options-menu.less @@ -0,0 +1,41 @@ +.options-menu { + position: absolute; + z-index: 20; + + width: 140px; + padding: 7px 0; + + background-color: #282828; + .roundedCorners(3px); + + top: 15px; + right: 0; + + .drop-shadow-box-spread(0, 0, 2px, 2px, #000000, 5); + + a { + display: block; + line-height: 24px; + font-size: 11px; + text-align: left; + color: #f7f7f7; + padding: 0 10px; + text-decoration: none; + + i { + line-height: 24px; + text-align: left; + width: 18px; + color: #f7f7f7; + } + + &:hover { + background-color: @adminPrimary; + color: #ffffff; + + i { + color: #ffffff; + } + } + } +} diff --git a/assets/less/components/overlay.less b/assets/less/components/overlay.less new file mode 100644 index 000000000..a7e975d23 --- /dev/null +++ b/assets/less/components/overlay.less @@ -0,0 +1,42 @@ +.big-overlay { + position: fixed; + top: 0; left: 0; right: 0; bottom: 0; + + overflow-y: auto; + overflow-x: hidden; + z-index: 99; + + >.background { + position: fixed; + top: 0; left: 0; right: 0; bottom: 0; + opacity: 0; + background-color: rgba(0, 0, 0, 0.85); + } + + >.content { + opacity: 0; + } + + .close-button { + display: inline-block; + position: fixed; + top: 20px; + right: 20px; + text-align: center; + width: 35px; + height: 35px; + cursor: pointer; + + i { + font-size: 24px; + line-height: 35px; + color: #cccccc; + } + + &:hover { + i { + color: #ffffff; + } + } + } +} diff --git a/assets/less/components/page-builder/canvas.less b/assets/less/components/page-builder/canvas.less new file mode 100644 index 000000000..4e8c7eeff --- /dev/null +++ b/assets/less/components/page-builder/canvas.less @@ -0,0 +1,19 @@ +.page-builder-canvas { + position: absolute; + top: 0; + left: 0; + bottom: 0; + right: 0; + background-color: #efefef; + overflow-y: auto; + overflow-x: hidden; + .transform(translateX(0px)); // makes fixed positioned elements relative to the canvas + .body-element { + .drop-shadow-box-spread(0, 0, 8px, 8px, #000000, 10); + } +} + +.preview .page-builder-canvas { + left: 0; + bottom: 0; +} diff --git a/assets/less/components/page-builder/chrome/general-menu.less b/assets/less/components/page-builder/chrome/general-menu.less new file mode 100644 index 000000000..e4f8b0568 --- /dev/null +++ b/assets/less/components/page-builder/chrome/general-menu.less @@ -0,0 +1,82 @@ +.pb-menu{ + position: absolute; + top: 0; + left: 0; + bottom: 0; + z-index: 4; + + overflow: hidden; + width: 0px; + .transition(0.4s, all, cubic-bezier(0.190, 1.000, 0.220, 1.000)); + + background-color: @pageBuilderMenu; + + // content wraper + .menu-wrapper { + position: relative; + height: 100%; + width: 200px; + .transition(0.4s, all, cubic-bezier(0.190, 1.000, 0.220, 1.000)); + + a { + display: block; + line-height: 40px; + height: 40px; + margin-bottom: 24px; + + text-transform: uppercase; + text-decoration: none; + font-size: 14px; + color: @pageBuilderMenuText; + + i { + text-align: center; + width: 40px; + padding: 0 6px; + margin-right: 10px; + font-size: 20px; + line-height: 40px; + } + + &:hover { + color: @pageBuilderMenuTextActive; + } + } + + .bottom { + position: absolute; + bottom: 0; + + a { + font-size: 13px; + } + .user { + margin-bottom: 12px; + span { + display: inline-block; + vertical-align: top; + } + .thumbnail { + display: inline-block; + width: 29px; + height: 29px; + overflow: hidden; + margin: 6px; + margin-right: 16px; + .roundedCorners(15px); + img { + vertical-align: top; + } + } + } + } + } + + // when opened + &.opened{ + width: 200px; + .menu-wrapper { + padding: 0 10px; + } + } +} diff --git a/assets/less/components/page-builder/chrome/index.less b/assets/less/components/page-builder/chrome/index.less new file mode 100644 index 000000000..4d9c0f54f --- /dev/null +++ b/assets/less/components/page-builder/chrome/index.less @@ -0,0 +1,2 @@ +@import './general-menu.less'; +@import './props-menu/index.less'; diff --git a/assets/less/components/page-builder/chrome/props-menu/breadcrumbs.less b/assets/less/components/page-builder/chrome/props-menu/breadcrumbs.less new file mode 100644 index 000000000..827ce1868 --- /dev/null +++ b/assets/less/components/page-builder/chrome/props-menu/breadcrumbs.less @@ -0,0 +1,32 @@ +.selected-breadcrumbs { + position: relative; + line-height: 23px; + border-bottom: 1px solid #2f3132; + background-color: #12171a; + padding: 0 7px; + + overflow: hidden; + white-space: nowrap; + direction: rtl; + text-align: left; + font-size: 12px; + + a { + text-decoration: none; + font-size: 10px; + color: #969696; + text-transform: capitalize; + &:hover { + color: #ffffff; + } + } + + span { + font-size: 10px; + color: #969696; + } + + .current { + color: #ffffff; + } +} diff --git a/assets/less/components/page-builder/chrome/props-menu/index.less b/assets/less/components/page-builder/chrome/props-menu/index.less new file mode 100644 index 000000000..7b91fa77b --- /dev/null +++ b/assets/less/components/page-builder/chrome/props-menu/index.less @@ -0,0 +1,123 @@ +.advanced-menu { + @import './breadcrumbs.less'; + @import './tabs/index.less'; + + @triggerButtonsSize: 35px; + + position: absolute; + z-index: 4; + + top: ~'calc(50% - 37vh)'; + right: -@pageBuilderAdvancedMenuWidth; + width: @pageBuilderAdvancedMenuWidth; + height: 75vh; + + background-color: @pageBuilderAdvancedMenu; + color: @pageBuilderChromeText; + + .transition(0.4s); + + &.opened { + right: 40px; + } + + &:before { + content: " "; + position: absolute; + left: -1px; right: -1px; top: -1px; bottom: -1px; + -webkit-box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.82); + -moz-box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.82); + box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.82); + } + + .content-scrollable { + position: absolute; + top: 66px; + bottom: 0; + left: 0; right: 0; + overflow-y: auto; + overflow-x: hidden; + } + + // tabs + .tabs { + position: relative; + border-bottom: 1px solid #2f3132; + .tab { + cursor: pointer; + display: inline-block; + vertical-align: top; + width: 33.3332%; + border-bottom: 2px solid rgba(0, 0, 0, 0); + color: #616363; + text-align: center; + font-size: 11px; + line-height: 37px; + text-transform: uppercase; + position: relative; + top: 1px; + + &.selected, &:hover { + color: #ffffff; + } + &.selected { + border-color: @adminPrimary; + } + } + } + + .menu-triggers { + position: absolute; + left: -@triggerButtonsSize - 1; + + top: 50%; + .transform(translateY(-50%)); + + &:before { + content: " "; + position: absolute; + left: -1px; right: -1px; top: -1px; bottom: -1px; + -webkit-box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.82); + -moz-box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.82); + box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.82); + } + + >div { + position: relative; + cursor: pointer; + width: @triggerButtonsSize; + height: @triggerButtonsSize; + background-color: @pageBuilderAdvancedMenu; + text-align: center; + margin-bottom: 1px; + border-radius: 2px 0 0 2px; + + i { + font-size: 16px; + color: #616363; + line-height: @triggerButtonsSize; + } + + &:hover { + i { + color: #ffffff; + } + } + } + } + + &.left { + right: auto; + left: -@pageBuilderAdvancedMenuWidth; + + &.opened { + right: auto; + left: 40px; + } + + .menu-triggers { + left: auto; + right: -@triggerButtonsSize - 1; + } + } +} diff --git a/assets/less/components/page-builder/chrome/props-menu/tabs/index.less b/assets/less/components/page-builder/chrome/props-menu/tabs/index.less new file mode 100644 index 000000000..fa601dd6f --- /dev/null +++ b/assets/less/components/page-builder/chrome/props-menu/tabs/index.less @@ -0,0 +1,3 @@ +@import './layers.less'; +@import './settings.less'; +@import './style.less'; diff --git a/assets/less/components/page-builder/chrome/props-menu/tabs/layers.less b/assets/less/components/page-builder/chrome/props-menu/tabs/layers.less new file mode 100644 index 000000000..7538227b6 --- /dev/null +++ b/assets/less/components/page-builder/chrome/props-menu/tabs/layers.less @@ -0,0 +1,152 @@ +.advanced-menu-structure { + padding: 10px; + h4 { + margin-top: 7px; + margin-bottom: 18px; + } + ul { + list-style-type: none; + padding: 0; + ul { + padding-left: 15px; + } + } + + .filter-display { + display: inline-block; + vertical-align: top; + width: 50%; + p { + margin: 0; + font-size: 11px; + font-weight: 600; + } + a { + text-decoration: none; + font-size: 11px; + color: #efefef; + .opacity(0.7); + + &:hover, &.active { + .opacity(1); + } + } + &.right { + text-align: right; + padding-top: 6px; + div { + line-height: 12px; + } + } + span { + font-size: 11px; + color: #999999; + } + } +} + +.structure-entry-element { + position: relative; + display: block; + text-align: left; + text-decoration: none; + + color: @pageBuilderAdvancedMenuText; + background-color: rgba(56, 60, 61, 0.5); + border: 1px solid rgba(0, 0, 0, 0); + font-size: 11px; + line-height: 25px; + margin-bottom: 1px; + padding: 0px 23px; + padding-right: 25px; + + height: 25px; + + &.sub-component { + .opacity(0.6); + } + + * { + vertical-align: top; + display: inline-block; + } + + >i { + width: 22px; + font-size: 12px; + line-height: 25px; + text-align: center; + position: absolute; + left: 0; top: 0; bottom: 0; + } + + >span { + line-height: 25px; + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; + width: 100%; + } + + >a, .options { + position: absolute; + top: 0; right: 0; bottom: 0; + display: inline-block; + width: 25px; + text-align: center; + line-height: 23px; + border-left: 1px solid #282828; + >i { + color: @pageBuilderAdvancedMenuText; + font-size: 10px; + line-height: 23px; + } + + &:hover { + background-color: @adminPrimary; + color: #fff; + } + } + + .options { + cursor: pointer; + visibility: hidden; + right: 0px; + >i { + font-size: 11px; + } + &:hover { + background-color: transparent; + >i { + color: @adminPrimary; + } + } + } + + &.hasChildren { + padding-right: 50px; + .options { + right: 25px; + } + } + + &.overed { + border: 1px solid @adminPrimary; + .options { + visibility: visible; + } + } + + &.selected { + border: 1px solid @adminPrimary; + background-color: @adminPrimary; + color: #ffffff; + + >a, .options { + border-left: 1px solid @adminPrimaryDarker; + &:hover { + background-color: @adminPrimaryDarker; + } + } + } +} diff --git a/assets/less/components/page-builder/chrome/props-menu/tabs/settings.less b/assets/less/components/page-builder/chrome/props-menu/tabs/settings.less new file mode 100644 index 000000000..936a2eb2c --- /dev/null +++ b/assets/less/components/page-builder/chrome/props-menu/tabs/settings.less @@ -0,0 +1,85 @@ +.settings-tab { + .content-scrollable { + top: 100px; + } + + .actions { + position: absolute; + top: 60px; + left: 0; + right: 0; + height: 30px; + border-bottom: 1px solid #2f3132; + background-color: #12171a; + + i, span { + display: inline-block; + line-height: 30px; + color: #616363; + font-size: 13px; + } + span { + font-size: 10px; + } + + >span { + text-align: center; + display: block; + } + + a { + display: inline-block; + vertical-align: top; + text-align: center; + text-decoration: none; + width: 50%; + margin: 0; + + &:hover { + i, span { + color: #ffffff; + } + } + } + } + + .edit-tab { + .element-info { + padding: 10px; + padding-top: 20px; + } + .element-options { + padding: 10px; + padding-top: 20px; + } + .none { + padding: 20px; + text-align: center; + } + + // Visible on option + .visibility { + margin-top: 10px; + a { + text-decoration: none; + display: inline-block; + color: #ffffff; + border-bottom: 2px solid #5ecf86; + width: 37px; + height: 37px; + text-align: center; + + i { + line-height: 37px; + } + + &:hover { + background-color: #333; + } + &.selected { + border-bottom: 2px solid @alert; + } + } + } + } +} diff --git a/assets/less/components/page-builder/chrome/props-menu/tabs/style.less b/assets/less/components/page-builder/chrome/props-menu/tabs/style.less new file mode 100644 index 000000000..63c89c734 --- /dev/null +++ b/assets/less/components/page-builder/chrome/props-menu/tabs/style.less @@ -0,0 +1,30 @@ +.styles-list { + .content-scrollable { + bottom: 40px; + } + .none-info { + color: #666; + padding: 30px 25px; + i { + display: block; + text-align: center; + font-size: 30px; + line-height: 50px; + } + div { + text-align: center; + font-size: 12px; + } + a { + display: block; + font-size: 11px; + line-height: 24px; + color: #cccccc; + text-align: center; + + &:hover { + color: @adminPrimary; + } + } + } +} diff --git a/assets/less/components/page-builder/context-menu.less b/assets/less/components/page-builder/context-menu.less new file mode 100644 index 000000000..e9625a741 --- /dev/null +++ b/assets/less/components/page-builder/context-menu.less @@ -0,0 +1,114 @@ +.context-menu { + position: absolute; + padding: 0 8px; + + background-color: @pageBuilderContextMenu; + .roundedCorners(20px); + + &.search { + .roundedCorners(20px, 20px, 0, 20px); + } + + a { + display: inline-block; + vertical-align: top; + line-height: 40px; + height: 40px; + width: 40px; + text-align: center; + + text-transform: uppercase; + text-decoration: none; + font-size: 14px; + color: @pageBuilderContextMenuText; + + i { + font-size: 20px; + line-height: 40px; + } + + &:hover { + color: @pageBuilderContextMenuTextActive; + } + } + + .seperator { + display: inline-block; + vertical-align: top; + position: relative; + width: 1px; + height: 22px; + top: 9px; + background-color: #b3b3b3; + } + + .main-elements { + display: inline-block; + vertical-align: top; + + div { + display: inline-block; + vertical-align: top; + } + } + + .autocomplete { + display: inline-block; + vertical-align: top; + padding: 0 10px; + min-width: 230px; + + span { + color: #666666; + } + + span.editable { + color: #ffffff; + &:focus { + outline: none; + border: 0; + } + } + } + + .dropdown { + position: absolute; + left: 48px; + right: 0; + background-color: #474747; + + div { + line-height: 40px; + color: #ffffff; + cursor: pointer; + + &:hover, &.active { + background-color: #757575; + } + + &.error { + text-align: center; + color: #666666; + padding: 0 5px; + } + + i { + font-size: 20px; + text-align: center; + width: 40px; + line-height: 40px; + } + span { + padding-right: 5px; + line-height: 40px; + color: #666666; + + &.active { + color: #ffffff; + padding-right: 0px; + padding-left: 5px; + } + } + } + } +} diff --git a/assets/less/components/page-builder/elements-menu.less b/assets/less/components/page-builder/elements-menu.less new file mode 100644 index 000000000..14444a479 --- /dev/null +++ b/assets/less/components/page-builder/elements-menu.less @@ -0,0 +1,108 @@ +.elements-menu { + width: 190px; + height: 240px; + text-align: left; + text-decoration: none; + z-index: 4; + position: fixed; + + .ballon { + width: 190px; + height: 240px; + border: 1px solid #d7d7d7; + .alphaColorToRgb(#e1e1e1, 90); + .roundedCorners(3px); + overflow: hidden; + position: relative; + } + + .arrow-left { + position: absolute; + top: 18px; + left: -8px; + width: 0; + height: 0; + border-top: 6px solid transparent; + border-bottom: 6px solid transparent; + border-right: 8px solid #d7d7d7; + } + + &.left { + .arrow-left { + left: auto; + right: -8px; + border-left: 8px solid #d7d7d7; + border-right: 0; + } + } + + .categories { + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; + } + + .category { + margin-bottom: 10px; + + &.collapsed { + margin-bottom: 0; + border-bottom: 1px solid #ccc; + } + } + + .category-info { + background-color: #d7d7d7; + color: #404040; + padding: 0 5px; + font-size: 10px; + text-transform: uppercase; + cursor: pointer; + line-height: 25px; + + i { + color: #404040; + float: right; + line-height: 25px; + font-size: 13px; + width: 40px; + text-align: center; + } + + &:hover { + background-color: #C5C5C5; + } + } + + .element-entry { + height: 35px; + cursor: pointer; + + i, span { + color: #5a5a5a; + line-height: 35px; + display: inline-block; + vertical-align: top; + } + + span { + font-size: 10px; + text-transform: uppercase; + } + + i { + width: 35px; + font-size: 15px; + text-align: center; + } + + &:hover, &.active { + background-color: @adminPrimary; + i, span { + color: #ffffff; + } + } + } +} diff --git a/assets/less/components/page-builder/general-elements-menu.less b/assets/less/components/page-builder/general-elements-menu.less new file mode 100644 index 000000000..df5d2067a --- /dev/null +++ b/assets/less/components/page-builder/general-elements-menu.less @@ -0,0 +1,187 @@ +.general-elements-menu { + @margin: 20px; + @buttonSize: 45px; + + @width: 300px; + @height: 500px; + + position: fixed; + bottom: @margin; + left: @margin; + + .toggle { + display: inline-block; + position: relative; + width: @buttonSize; + height: @buttonSize; + text-align: center; + background-color: @adminPrimary; + cursor: pointer; + + .roundedCorners(@buttonSize / 2); + .opacity(0.7); + + i { + color: #ffffff; + font-size: 30px; + line-height: @buttonSize; + .transition(); + } + + &:hover { + .opacity(1); + } + + &.opened { + background-color: @alert; + i { + transform: rotateZ(45deg); + } + } + } + + .opened-menu { + position: absolute; + bottom: 0; + left: 0; + + .search { + @verticalPadding: 10px; + width: @width; + height: @buttonSize; + position: relative; + padding: @verticalPadding; + padding-left: @buttonSize + 10px; + padding-right: 10px; + + background-color: #E8E8E8; + + .roundedCorners(@buttonSize / 2); + + >* { + display: inline-block; + vertical-align: top; + line-height: @buttonSize - (@verticalPadding * 2); + } + + >i { + margin-right: 10px; + font-size: 23px; + color: #cccccc; + } + + input { + border: 0; + outline: 0; + padding: 0 3px; + width: 180px; + background: transparent; + border-bottom: 1px solid #cccccc; + color: #333333; + + &:focus { + border-color: @adminPrimary; + } + } + } + + .list { + width: @width; + height: @height; + + position: absolute; + bottom: 0; + left: 0; + + background-color: #efefef; + overflow: hidden; + + .roundedCorners(3px, 3px, @buttonSize / 2, @buttonSize / 2); + } + + .categories { + position: absolute; + top: 0; + bottom: @buttonSize; + left: 0; + right: 0; + } + + .category { + margin-bottom: 10px; + + &.collapsed { + margin-bottom: 0; + border-bottom: 1px solid #ccc; + } + } + + .category-info { + background-color: #d7d7d7; + color: #404040; + padding: 0 5px; + font-size: 10px; + text-transform: uppercase; + cursor: pointer; + line-height: 25px; + + i { + color: #404040; + float: right; + line-height: 25px; + font-size: 13px; + width: 40px; + text-align: center; + } + + &:hover { + background-color: #C5C5C5; + } + } + } +} + +.general-em-element-entry { + height: 35px; + cursor: pointer; + position: relative; + background-color: #efefef; + + >i, >span { + color: #5a5a5a; + line-height: 35px; + display: inline-block; + vertical-align: top; + } + + >span { + font-size: 10px; + text-transform: uppercase; + } + + >i { + width: 35px; + font-size: 15px; + text-align: center; + } + + .drag-info { + position: absolute; + display: inline-block; + right: 25px; + top: 0; + i { + line-height: 35px; + font-size: 14px; + width: 5px; + color: #999; + } + } + + &:hover, &.active { + background-color: @adminPrimary; + i, >span { + color: #ffffff; + } + } +} diff --git a/assets/less/components/page-builder/index.less b/assets/less/components/page-builder/index.less new file mode 100644 index 000000000..4023bec19 --- /dev/null +++ b/assets/less/components/page-builder/index.less @@ -0,0 +1,14 @@ +@import './canvas.less'; +@import './context-menu.less'; +@import './chrome/index.less'; +@import './elements-menu.less'; +@import './general-elements-menu.less'; + +.page-builder { + position: fixed; + top: @pageBuilderTopMenuHeight; + bottom: 0; + left: 0; + right: 0; + z-index: 2; +} diff --git a/assets/less/components/preview-style.less b/assets/less/components/preview-style.less new file mode 100644 index 000000000..9d7ca048e --- /dev/null +++ b/assets/less/components/preview-style.less @@ -0,0 +1,116 @@ +.preview-style { + position: relative; + border: solid 1px #333333; + + .roundedCorners (3px); + .transition(); + + .preview-style-content { + position: relative; + background-color: #383838; + cursor: pointer; + .item { + border: 0; + } + } + + .preview-style-list { + position: absolute; + left: -1px; bottom: -1px; right: -1px; + height: 300px; + + background-color: #383838; + border: solid 1px @adminPrimary; + + .roundedCorners (3px); + + p { + margin: 0; + padding: 55px 22px; + font-size: 12px; + } + + .scrollable { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 35px; + overflow-y: auto; + } + + .add-new { + display: block; + position: absolute; + bottom: 0; + left: 0; + right: 0; + height: 35px; + + text-align: center; + text-decoration: none; + color: #efefef; + border-top: 1px solid #333333; + line-height: 35px; + font-size: 12px; + + i { + font-size: 10px; + } + + &:hover { + background-color: #333333; + } + } + } + + .item { + padding: 11px 10px; + cursor: pointer; + border-left: 5px solid #333; + .transition(); + + .preview { + padding-bottom: 5px; + word-wrap: break-word; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + width: 100%; + } + .info { + font-size: 12px; + color: #999; + a { + float: right; + width: 20px; height: 20px; + .roundedCorners(3px); + text-align: center; + line-height: 20px; + color: #999; + + &:hover { + background-color: @adminPrimary; + color: #fff; + } + } + } + + &.white-background { + background-color: #efefef; + border-color: #ccc; + } + + &:hover, &.active { + border-color: @adminPrimary; + } + } + + .preview-style-options { + padding: 15px 10px; + } + + &:hover { + border-color: @adminPrimary; + } +} diff --git a/assets/less/components/schema-link.less b/assets/less/components/schema-link.less new file mode 100644 index 000000000..910c4fa32 --- /dev/null +++ b/assets/less/components/schema-link.less @@ -0,0 +1,31 @@ +.schema-link { + + .fields { + margin-top: 20px; + } + + .schema-link-field { + background-color: #3F3F3F; + padding: 0 7px; + margin-bottom: 4px; + border: 1px solid #3F3F3F; + + .roundedCorners(3px); + + &:hover, &.opened { + border-color: @adminPrimary; + } + + >.label { + text-decoration: none; + display: block; + line-height: 30px; + margin-bottom: 0px; + + i { + line-height: 30px; + float: right; + } + } + } +} diff --git a/assets/less/components/spacing-picker.less b/assets/less/components/spacing-picker.less new file mode 100644 index 000000000..b48ceb885 --- /dev/null +++ b/assets/less/components/spacing-picker.less @@ -0,0 +1,191 @@ +.spacing-picker { + @btnsSize: 25px; + @btnsSpacing: 3px; + @total: @btnsSize * 3 + @btnsSpacing * 2; + + display: table; + width: 100%; + table-layout: fixed; + margin-top: 10px; + + // Parts + .toggles, .inputs { + display: table-cell; + vertical-align: middle; + } + + .toggles { + position: relative; + height: @total; + width: @total; + } + + .inputs { + padding-left: 25px; + padding-bottom: 13px; + + .sub-label { + font-size: 9px; + color: #616363; + text-transform: uppercase; + margin-bottom: 5px; + } + } + + // Toggle buttons + .toggle { + position: absolute; + width: @btnsSize; + height: @btnsSize; + border: 1px solid #383838; + text-align: center; + cursor: pointer; + + i { + color: #cccccc; + font-size: 15px; + line-height: 23px; + position: relative; + } + + @center: @total / 2 - @btnsSize / 2; + + &.top { + left: @center; + top: 0; + } + &.left { + left: 0; + top: @center; + } + &.center { + left: @center; + top: @center; + } + &.right { + right: 0; + top: @center; + } + &.bottom { + left: @center; + bottom: 0; + } + + &:before { + content: " "; + position: absolute; + background-color: #cccccc; + } + &.top:before, &.bottom:before { + height: 1px; + width: 9px; + left: @btnsSize / 2 - 6px; + } + &.left:before, &.right:before { + height: 9px; + width: 1px; + top: @btnsSize / 2 - 6px; + } + + + + &:hover { + background-color: #383838; + i { + color: #ffffff; + } + &:before { + background-color: #ffffff; + } + } + &.selected { + border-color: @adminPrimary; + background-color: #383838; + i { + color: #ffffff; + } + &:before { + background-color: #ffffff; + } + } + &.active { + i { + color: @adminPrimary; + } + &:before { + background-color: @adminPrimary; + } + } + } + + // Type + &.type-padding { + .top { + &:before { + top: 7px; + } + i { + top: 3px; + } + } + .bottom { + &:before { + bottom: 7px; + } + i { + top: -3px; + } + } + .left { + &:before { + left: 7px; + } + i { + left: 3px; + } + } + .right { + &:before { + right: 7px; + } + i { + left: -3px; + } + } + } + &.type-margin { + .top { + &:before { + bottom: 7px; + } + i { + top: -3px; + } + } + .bottom { + &:before { + top: 7px; + } + i { + top: 3px; + } + } + .left { + &:before { + right: 7px; + } + i { + left: -3px; + } + } + .right { + &:before { + left: 7px; + } + i { + left: 3px; + } + + } + } +} diff --git a/assets/less/components/spinner.less b/assets/less/components/spinner.less new file mode 100644 index 000000000..0bf3db07d --- /dev/null +++ b/assets/less/components/spinner.less @@ -0,0 +1,34 @@ +// Bar spinner (check) +.spinner { + display: inline-block; + font-size:10px; + position:relative; + text-indent:-9999em; + border-top: 3px solid #3EB0F2; + border-right:3px solid #DADADA; + border-bottom:3px solid #DADADA; + border-left:3px solid #DADADA; + -webkit-transform: translateZ(0); + -ms-transform: translateZ(0); + transform: translateZ(0); + -webkit-animation:sk-bar-spinner-frames 1.1s infinite linear; + animation:sk-bar-spinner-frames 1.1s infinite linear; +} +.spinner, .spinner:after { + border-radius:50%; + width: 20px; + height: 20px; +} +@-webkit-keyframes sk-bar-spinner-frames {.sk-bar-spinner-frames;} +@keyframes sk-bar-spinner-frames {.sk-bar-spinner-frames;} + +.sk-bar-spinner-frames() { + 0% { + -webkit-transform:rotate(0deg); + transform:rotate(0deg); + } + 100% { + -webkit-transform:rotate(360deg); + transform:rotate(360deg); + } +} diff --git a/assets/less/components/style-picker/edit.less b/assets/less/components/style-picker/edit.less new file mode 100644 index 000000000..54601de69 --- /dev/null +++ b/assets/less/components/style-picker/edit.less @@ -0,0 +1,29 @@ +.edit-style { + @bottomHeight: 40px; + .complement-content-scrollable { + bottom: @bottomHeight; + } + .buttons-group { + position: absolute; + bottom: 0; + left: 0; + right: 0; + height: @bottomHeight; + border-top: 1px solid #383838; + + >* { + cursor: pointer; + display: inline-block; + vertical-align: top; + width: 50%; + height: @bottomHeight; + line-height: @bottomHeight; + text-align: center; + color: #616363; + font-size: 14px; + &:hover { + color: #ffffff; + } + } + } +} diff --git a/assets/less/components/style-picker/entry.less b/assets/less/components/style-picker/entry.less new file mode 100644 index 000000000..5c5b55ae4 --- /dev/null +++ b/assets/less/components/style-picker/entry.less @@ -0,0 +1,76 @@ +.entry { + position: relative; + cursor: pointer; + padding: 20px 10px; + border-bottom: 1px solid #2f3132; + + .info-holder { + display: table; + width: 100%; + table-layout: fixed; + >* { + display: table-cell; + vertical-align: top; + } + } + .title { + font-size: 10px; + text-transform: uppercase; + color: #606162; + letter-spacing: 1px; + } + .info { + font-size: 10px; + color: #efefef; + float: right; + } + + &:hover, &.selected { + background-color: #12171a; + } + &.selected { + border-left: 3px solid #3eb0f2; + } + &.editing { + border-left: 3px solid #3CB133; + } + + &.contrast { + background-color: rgba(255, 255, 255, 0.85); + &:hover, &.selected { + background-color: rgba(255, 255, 255, 1); + } + .title { + color: #888888; + } + .info { + color: #424242; + } + } + + .options-btn { + position: absolute; + bottom: 0; right: 0; + width: 25px; height: 25px; + visibility: hidden; + text-align: center; + background-color: rgba(0, 0, 0, 0.4); + .roundedCorners(3px, 0, 0, 0); + + >i { + font-size: 16px; + line-height: 25px; + color: #cccccc; + } + + &:hover { + background-color: rgba(0, 0, 0, 0.7); + >i { + color: #ffffff; + } + } + } + &:hover .options-btn { + visibility: visible; + } +} diff --git a/assets/less/components/style-picker/index.less b/assets/less/components/style-picker/index.less new file mode 100644 index 000000000..7a933409e --- /dev/null +++ b/assets/less/components/style-picker/index.less @@ -0,0 +1,31 @@ +.style-picker { + @import './entry.less'; + @import './edit.less'; + + .add-style-btn { + position: absolute; + bottom: 0; left: 0; right: 0; + + height: 40px; + line-height: 40px; + border-top: 1px solid #383838; + text-align: center; + color: #616363; + cursor: pointer; + + i, span { + display: inline-block; + vertical-align: top; + color: #616363; + font-size: 14px; + line-height: 40px; + margin-right: 5px; + } + + &:hover { + i, span { + color: #ffffff; + } + } + } +} diff --git a/assets/less/components/style.less b/assets/less/components/style.less new file mode 100644 index 000000000..23ae98892 --- /dev/null +++ b/assets/less/components/style.less @@ -0,0 +1,77 @@ +.style-picker { + @entryHeight: 34px; + + .style-options-group { + padding: 15px 10px; + background-color: #3F3F3F; + } + + .style-entry { + position: relative; + display: block; + padding: 0px 10px; + background-color: #333; + color: #f7f7f7; + border: 1px solid #333; + margin-bottom: 1px; + text-decoration: none; + padding-right: 50px; + + >span { + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; + width: 100%; + font-size: 14px; + line-height: @entryHeight; + } + + .style-btn { + cursor: pointer; + position: absolute; + top: 0; right: 0; bottom: 0; + display: inline-block; + width: 25px; + text-align: center; + line-height: @entryHeight - 2; + border-left: 1px solid #282828; + >i { + color: @pageBuilderAdvancedMenuText; + font-size: 10px; + line-height: @entryHeight - 2; + } + + &:hover { + background-color: @adminPrimary; + color: #fff; + } + } + + .options { + visibility: hidden; + right: 25px; + >i { + font-size: 11px; + } + } + + &:hover { + border-color: @adminPrimary; + + .options { + visibility: visible; + } + } + &.selected { + border-color: @adminPrimary; + background-color: @adminPrimary; + color: #fff; + .style-btn { + border-left: 1px solid @adminPrimaryDarker; + &:hover { + background-color: @adminPrimaryDarker; + } + } + } + } +} diff --git a/assets/less/components/table.less b/assets/less/components/table.less new file mode 100644 index 000000000..0f73bf2c5 --- /dev/null +++ b/assets/less/components/table.less @@ -0,0 +1,27 @@ +table{ + width: 100%; + + td, th{ + padding: 10px; + text-align: left; + } + + thead { + border-bottom: 1px solid #efefef; + } + th { + padding: 13px 15px; + text-align: left; + font-size: 15px; + color: #333; + } + td { + padding: 7px 15px; + font-size: 14px; + color: #444444; + border: 0; + } + tbody tr:nth-child(odd) { + background-color: #FDFDFD; + } +} diff --git a/assets/less/components/upload.less b/assets/less/components/upload.less new file mode 100644 index 000000000..e80b55049 --- /dev/null +++ b/assets/less/components/upload.less @@ -0,0 +1,399 @@ +/* + * The MIT License + * Copyright (c) 2012 Matias Meno + */ +@-webkit-keyframes passing-through { + 0% { + opacity: 0; + -webkit-transform: translateY(40px); + -moz-transform: translateY(40px); + -ms-transform: translateY(40px); + -o-transform: translateY(40px); + transform: translateY(40px); } + 30%, 70% { + opacity: 1; + -webkit-transform: translateY(0px); + -moz-transform: translateY(0px); + -ms-transform: translateY(0px); + -o-transform: translateY(0px); + transform: translateY(0px); } + 100% { + opacity: 0; + -webkit-transform: translateY(-40px); + -moz-transform: translateY(-40px); + -ms-transform: translateY(-40px); + -o-transform: translateY(-40px); + transform: translateY(-40px); } } +@-moz-keyframes passing-through { + 0% { + opacity: 0; + -webkit-transform: translateY(40px); + -moz-transform: translateY(40px); + -ms-transform: translateY(40px); + -o-transform: translateY(40px); + transform: translateY(40px); } + 30%, 70% { + opacity: 1; + -webkit-transform: translateY(0px); + -moz-transform: translateY(0px); + -ms-transform: translateY(0px); + -o-transform: translateY(0px); + transform: translateY(0px); } + 100% { + opacity: 0; + -webkit-transform: translateY(-40px); + -moz-transform: translateY(-40px); + -ms-transform: translateY(-40px); + -o-transform: translateY(-40px); + transform: translateY(-40px); } } +@keyframes passing-through { + 0% { + opacity: 0; + -webkit-transform: translateY(40px); + -moz-transform: translateY(40px); + -ms-transform: translateY(40px); + -o-transform: translateY(40px); + transform: translateY(40px); } + 30%, 70% { + opacity: 1; + -webkit-transform: translateY(0px); + -moz-transform: translateY(0px); + -ms-transform: translateY(0px); + -o-transform: translateY(0px); + transform: translateY(0px); } + 100% { + opacity: 0; + -webkit-transform: translateY(-40px); + -moz-transform: translateY(-40px); + -ms-transform: translateY(-40px); + -o-transform: translateY(-40px); + transform: translateY(-40px); } } +@-webkit-keyframes slide-in { + 0% { + opacity: 0; + -webkit-transform: translateY(40px); + -moz-transform: translateY(40px); + -ms-transform: translateY(40px); + -o-transform: translateY(40px); + transform: translateY(40px); } + 30% { + opacity: 1; + -webkit-transform: translateY(0px); + -moz-transform: translateY(0px); + -ms-transform: translateY(0px); + -o-transform: translateY(0px); + transform: translateY(0px); } } +@-moz-keyframes slide-in { + 0% { + opacity: 0; + -webkit-transform: translateY(40px); + -moz-transform: translateY(40px); + -ms-transform: translateY(40px); + -o-transform: translateY(40px); + transform: translateY(40px); } + 30% { + opacity: 1; + -webkit-transform: translateY(0px); + -moz-transform: translateY(0px); + -ms-transform: translateY(0px); + -o-transform: translateY(0px); + transform: translateY(0px); } } +@keyframes slide-in { + 0% { + opacity: 0; + -webkit-transform: translateY(40px); + -moz-transform: translateY(40px); + -ms-transform: translateY(40px); + -o-transform: translateY(40px); + transform: translateY(40px); } + 30% { + opacity: 1; + -webkit-transform: translateY(0px); + -moz-transform: translateY(0px); + -ms-transform: translateY(0px); + -o-transform: translateY(0px); + transform: translateY(0px); } } +@-webkit-keyframes pulse { + 0% { + -webkit-transform: scale(1); + -moz-transform: scale(1); + -ms-transform: scale(1); + -o-transform: scale(1); + transform: scale(1); } + 10% { + -webkit-transform: scale(1.1); + -moz-transform: scale(1.1); + -ms-transform: scale(1.1); + -o-transform: scale(1.1); + transform: scale(1.1); } + 20% { + -webkit-transform: scale(1); + -moz-transform: scale(1); + -ms-transform: scale(1); + -o-transform: scale(1); + transform: scale(1); } } +@-moz-keyframes pulse { + 0% { + -webkit-transform: scale(1); + -moz-transform: scale(1); + -ms-transform: scale(1); + -o-transform: scale(1); + transform: scale(1); } + 10% { + -webkit-transform: scale(1.1); + -moz-transform: scale(1.1); + -ms-transform: scale(1.1); + -o-transform: scale(1.1); + transform: scale(1.1); } + 20% { + -webkit-transform: scale(1); + -moz-transform: scale(1); + -ms-transform: scale(1); + -o-transform: scale(1); + transform: scale(1); } } +@keyframes pulse { + 0% { + -webkit-transform: scale(1); + -moz-transform: scale(1); + -ms-transform: scale(1); + -o-transform: scale(1); + transform: scale(1); } + 10% { + -webkit-transform: scale(1.1); + -moz-transform: scale(1.1); + -ms-transform: scale(1.1); + -o-transform: scale(1.1); + transform: scale(1.1); } + 20% { + -webkit-transform: scale(1); + -moz-transform: scale(1); + -ms-transform: scale(1); + -o-transform: scale(1); + transform: scale(1); } } +.dropzone, .dropzone * { + box-sizing: border-box; } + +.dropzone { + min-height: 150px; + border: 2px solid @adminPrimary; + padding: 20px 20px; + .roundedCorners(3px); +} + .dropzone.dz-clickable { + cursor: pointer; } + .dropzone.dz-clickable * { + cursor: default; } + .dropzone.dz-clickable .dz-message, .dropzone.dz-clickable .dz-message * { + cursor: pointer; } + .dropzone.dz-started .dz-message { + display: none; } + .dropzone.dz-drag-hover { + border-style: solid; } + .dropzone.dz-drag-hover .dz-message { + opacity: 0.5; } + .dropzone .dz-message { + text-align: center; + margin: 41px 0; + font-size: 14px; + text-transform: uppercase; + color: #666666; + } + .dropzone .dz-preview { + position: relative; + display: inline-block; + vertical-align: top; + margin: 16px; + min-height: 100px; } + .dropzone .dz-preview:hover { + z-index: 1000; } + .dropzone .dz-preview:hover .dz-details { + opacity: 1; } + .dropzone .dz-preview.dz-file-preview .dz-image { + border-radius: 20px; + background: #999; + background: linear-gradient(to bottom, #eee, #ddd); + } + .dropzone .dz-preview.dz-file-preview .dz-details { + opacity: 1; } + .dropzone .dz-preview.dz-image-preview { + background: white; + + .dz-image img{ + min-width: 100%; + } + } + .dropzone .dz-preview.dz-image-preview .dz-details { + -webkit-transition: opacity 0.2s linear; + -moz-transition: opacity 0.2s linear; + -ms-transition: opacity 0.2s linear; + -o-transition: opacity 0.2s linear; + transition: opacity 0.2s linear; } + .dropzone .dz-preview .dz-remove { + font-size: 14px; + text-align: center; + display: block; + cursor: pointer; + border: none; } + .dropzone .dz-preview .dz-remove:hover { + text-decoration: underline; } + .dropzone .dz-preview:hover .dz-details { + opacity: 1; } + .dropzone .dz-preview .dz-details { + z-index: 20; + position: absolute; + top: 0; + left: 0; + opacity: 0; + font-size: 13px; + min-width: 100%; + max-width: 100%; + padding: 2em 1em; + text-align: center; + color: rgba(0, 0, 0, 0.9); + line-height: 150%; } + .dropzone .dz-preview .dz-details .dz-size { + margin-bottom: 1em; + font-size: 16px; } + .dropzone .dz-preview .dz-details .dz-filename { + white-space: nowrap; } + .dropzone .dz-preview .dz-details .dz-filename:hover span { + border: 1px solid rgba(200, 200, 200, 0.8); + background-color: rgba(255, 255, 255, 0.8); } + .dropzone .dz-preview .dz-details .dz-filename:not(:hover) { + overflow: hidden; + text-overflow: ellipsis; } + .dropzone .dz-preview .dz-details .dz-filename:not(:hover) span { + border: 1px solid transparent; } + .dropzone .dz-preview .dz-details .dz-filename span, .dropzone .dz-preview .dz-details .dz-size span { + background-color: rgba(255, 255, 255, 0.4); + padding: 0 0.4em; + border-radius: 3px; } + .dropzone .dz-preview:hover .dz-image img { + -webkit-transform: scale(1.05, 1.05); + -moz-transform: scale(1.05, 1.05); + -ms-transform: scale(1.05, 1.05); + -o-transform: scale(1.05, 1.05); + transform: scale(1.05, 1.05); + -webkit-filter: blur(8px); + filter: blur(8px); } + .dropzone .dz-preview .dz-image { + border-radius: 20px; + overflow: hidden; + width: 120px; + height: 120px; + position: relative; + display: block; + z-index: 10; } + .dropzone .dz-preview .dz-image img { + display: block; } + .dropzone .dz-preview.dz-success .dz-success-mark { + -webkit-animation: passing-through 3s cubic-bezier(0.77, 0, 0.175, 1); + -moz-animation: passing-through 3s cubic-bezier(0.77, 0, 0.175, 1); + -ms-animation: passing-through 3s cubic-bezier(0.77, 0, 0.175, 1); + -o-animation: passing-through 3s cubic-bezier(0.77, 0, 0.175, 1); + animation: passing-through 3s cubic-bezier(0.77, 0, 0.175, 1); } + .dropzone .dz-preview.dz-error .dz-error-mark { + opacity: 1; + -webkit-animation: slide-in 3s cubic-bezier(0.77, 0, 0.175, 1); + -moz-animation: slide-in 3s cubic-bezier(0.77, 0, 0.175, 1); + -ms-animation: slide-in 3s cubic-bezier(0.77, 0, 0.175, 1); + -o-animation: slide-in 3s cubic-bezier(0.77, 0, 0.175, 1); + animation: slide-in 3s cubic-bezier(0.77, 0, 0.175, 1); } + .dropzone .dz-preview .dz-success-mark, .dropzone .dz-preview .dz-error-mark { + pointer-events: none; + opacity: 0; + z-index: 500; + position: absolute; + display: block; + top: 50%; + left: 50%; + margin-left: -27px; + margin-top: -27px; } + .dropzone .dz-preview .dz-success-mark svg, .dropzone .dz-preview .dz-error-mark svg { + display: block; + width: 54px; + height: 54px; } + .dropzone .dz-preview.dz-processing .dz-progress { + opacity: 1; + -webkit-transition: all 0.2s linear; + -moz-transition: all 0.2s linear; + -ms-transition: all 0.2s linear; + -o-transition: all 0.2s linear; + transition: all 0.2s linear; } + .dropzone .dz-preview.dz-complete .dz-progress { + opacity: 0; + -webkit-transition: opacity 0.4s ease-in; + -moz-transition: opacity 0.4s ease-in; + -ms-transition: opacity 0.4s ease-in; + -o-transition: opacity 0.4s ease-in; + transition: opacity 0.4s ease-in; } + .dropzone .dz-preview:not(.dz-processing) .dz-progress { + -webkit-animation: pulse 6s ease infinite; + -moz-animation: pulse 6s ease infinite; + -ms-animation: pulse 6s ease infinite; + -o-animation: pulse 6s ease infinite; + animation: pulse 6s ease infinite; } + .dropzone .dz-preview .dz-progress { + opacity: 1; + z-index: 1000; + pointer-events: none; + position: absolute; + height: 16px; + left: 50%; + top: 50%; + margin-top: -8px; + width: 80px; + margin-left: -40px; + background: rgba(255, 255, 255, 0.9); + -webkit-transform: scale(1); + border-radius: 8px; + overflow: hidden; } + .dropzone .dz-preview .dz-progress .dz-upload { + background: #333; + background: linear-gradient(to bottom, #666, #444); + position: absolute; + top: 0; + left: 0; + bottom: 0; + width: 0; + -webkit-transition: width 300ms ease-in-out; + -moz-transition: width 300ms ease-in-out; + -ms-transition: width 300ms ease-in-out; + -o-transition: width 300ms ease-in-out; + transition: width 300ms ease-in-out; } + .dropzone .dz-preview.dz-error .dz-error-message { + display: block; } + .dropzone .dz-preview.dz-error:hover .dz-error-message { + opacity: 1; + pointer-events: auto; } + .dropzone .dz-preview .dz-error-message { + pointer-events: none; + z-index: 1000; + position: absolute; + display: block; + display: none; + opacity: 0; + -webkit-transition: opacity 0.3s ease; + -moz-transition: opacity 0.3s ease; + -ms-transition: opacity 0.3s ease; + -o-transition: opacity 0.3s ease; + transition: opacity 0.3s ease; + border-radius: 8px; + font-size: 13px; + top: 130px; + left: -10px; + width: 140px; + background: #be2626; + background: linear-gradient(to bottom, #be2626, #a92222); + padding: 0.5em 1.2em; + color: white; } + .dropzone .dz-preview .dz-error-message:after { + content: ''; + position: absolute; + top: -6px; + left: 64px; + width: 0; + height: 0; + border-left: 6px solid transparent; + border-right: 6px solid transparent; + border-bottom: 6px solid #be2626; } diff --git a/assets/less/functions.less b/assets/less/functions.less new file mode 100644 index 000000000..d80133795 --- /dev/null +++ b/assets/less/functions.less @@ -0,0 +1,122 @@ + +// Maxes a div size to stick 0 pixels from the borders around +.maxedSize(){ + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; +} + +// Alpha color background +.alphaColor(@r, @g, @b, @a){ + background: rgb(@r, @g, @b); + background: rgba(@r, @g, @b, @a); +} + +.alphaColorToRgb(@color, @alpha) when (@alpha > 1) { + .alphaColor(red(@color), green(@color), blue(@color), @alpha/100); +} +.alphaColorToRgb(@color, @alpha) when (@alpha =< 1) { + .alphaColor(red(@color), green(@color), blue(@color), @alpha); +} + +/*Gradient*/ +.gradient(@color1, @color2, @perc1: 50%, @perc2: 50%){ + background-color: @color2; + + background-image: linear-gradient(bottom, @color1 @perc1, @color2 @perc2); + background-image: -o-linear-gradient(bottom, @color1 @perc1, @color2 @perc2); + background-image: -moz-linear-gradient(bottom, @color1 @perc1, @color2 @perc2); + background-image: -webkit-linear-gradient(bottom, @color1 @perc1, @color2 @perc2); + background-image: -ms-linear-gradient(bottom, @color1 @perc1, @color2 @perc2); + + background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0.5, @color1), color-stop(0.5, @color2)); +} + +/*Drop Shadow*/ +.drop-shadow-box(@x-axis: 0, @y-axis: 1px, @blur: 2px, @color, @alpha){ + box-shadow: @x-axis @y-axis @blur rgba(red(@color), green(@color), blue(@color), @alpha/100); +} +.drop-shadow-box-spread(@x-axis: 0, @y-axis: 1px, @blur: 2px, @spread: 2px, @color, @alpha){ + box-shadow: @x-axis @y-axis @blur @spread rgba(red(@color), green(@color), blue(@color), @alpha/100); +} +.drop-shadow(@x-axis: 0, @y-axis: 1px, @blur: 2px, @r: 0, @g: 0, @b: 0, @alpha: 0.1) { + -webkit-text-shadow: @x-axis @y-axis @blur rgba(@r, @g, @b, @alpha); + -moz-text-shadow: @x-axis @y-axis @blur rgba(@r, @g, @b, @alpha); + text-shadow: @x-axis @y-axis @blur rgba(@r, @g, @b, @alpha); +} + +/*Rounded Corners*/ +.roundedCorners(@rad: 2px, @other: false) when (@other = false) { + -webkit-border-radius : @rad; + -moz-border-radius : @rad; + -o-border-radius : @rad; + border-radius : @rad; +} +.roundedCorners(@tl_rad: 0, @tr_rad: false, @br_rad: 0, @bl_rad: 0) when not (@tr_rad = false){ + -webkit-border-radius : @tl_rad @tr_rad @br_rad @bl_rad; + -moz-border-radius : @tl_rad @tr_rad @br_rad @bl_rad; + -o-border-radius : @tl_rad @tr_rad @br_rad @bl_rad; + border-radius : @tl_rad @tr_rad @br_rad @bl_rad; +} + +// Border Colors +.border(@size, @style, @color, @opc){ + border: @size @style rgba(red(@color), green(@color), blue(@color), @opc/100); + -webkit-background-clip: padding-box; + background-clip: padding-box; +} + +/*Transition*/ +.transition (@time: 0.2s, @to: all, @ease: cubic-bezier(0.190, 1.000, 0.220, 1.000)) { + transition : @to @time @ease; + -webkit-transition : @to @time @ease; + -moz-transition : @to @time @ease; + -o-transition : @to @time @ease; +} + +/*Transition for transform only*/ +.transitionTransform (@time: 0.2s, @ease: cubic-bezier(0.190, 1.000, 0.220, 1.000)){ + transition : transform @time @ease; + -ms-transition: -ms-transform @time @ease; + -webkit-transition : -webkit-transform @time @ease; + -moz-transition : -moz-transform @time @ease; + -o-transition : -o-transform @time @ease; +} + +/*Transition Delay*/ +.transitionDelay (@time: 0.2s) { + transition-delay : @time; + -webkit-transition-delay : @time; + -moz-transition-delay : @time; + -o-transition-delay : @time; +} + +/*Opacity*/ +.opacity(@opacity: 0.5) { + @percentage: @opacity*100; + ms-filter: ~"progid:DXImageTransform.Microsoft.Alpha(Opacity=@{percentage})"; + filter: ~"alpha(opacity=@{percentage})"; + -moz-opacity: @opacity; + -khtml-opacity: @opacity; + -webkit-opacity: @opacity; + opacity: @opacity; +} + + +.transformOrigin(@x, @y){ + transform-origin: @x @y; + -ms-transform-origin: @x @y; /* IE 9 */ + -webkit-transform-origin: @x @y; /* Safari and Chrome */ + -moz-transform-origin: @x @y; /* Firefox */ + -o-transform-origin: @x @y; /* Opera */ +} + +.transform(@values){ + transform: @values; + -ms-transform: @values; /* IE 9 */ + -moz-transform: @values; /* Firefox */ + -webkit-transform: @values; /* Safari and Chrome */ + -o-transform: @values; /* Opera */ +} diff --git a/assets/less/main.less b/assets/less/main.less new file mode 100644 index 000000000..1c788591a --- /dev/null +++ b/assets/less/main.less @@ -0,0 +1,19 @@ +body { + font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; +} + +img { + max-width: 100%; +} + +@import './variables.less'; + +// Less functions +@import './functions.less'; + +// boilerplate +@import './boilerplate/normalize.less'; +@import './boilerplate/main.less'; + +// components +@import './components/index.less'; diff --git a/assets/less/variables.less b/assets/less/variables.less new file mode 100644 index 000000000..1b2f8f58f --- /dev/null +++ b/assets/less/variables.less @@ -0,0 +1,39 @@ +@adminPrimary: #3eb0f2; +@adminPrimaryLight: lighten(@adminPrimary, 20%); +@adminPrimaryDarker: darken(@adminPrimary, 20%); + +@alert: #D22525; +@alertDarker: #8A1212; + +@success: #17B923; + +@pageBuilderChrome: #1d1c1c; +@pageBuilderChromeText: #f7f7f7; +@pageBuilderChromeTextActive: #ffffff; + +@pageBuilderMenu: @pageBuilderChrome; +@pageBuilderMenuText: @pageBuilderChromeText; +@pageBuilderMenuTextActive: @pageBuilderChromeTextActive; + +@pageBuilderTopMenu: #1d1c1c; +@pageBuilderTopMenuText: @pageBuilderChromeText; +@pageBuilderTopMenuTextActive: @pageBuilderChromeTextActive; +@pageBuilderTopMenuHeight: 60px; + +@pageBuilderContextMenu: @pageBuilderChrome; +@pageBuilderContextMenuText: @pageBuilderChromeText; +@pageBuilderContextMenuTextActive: @pageBuilderChromeTextActive; + +@pageBuilderAdvancedMenu: fade(#131618, 95%); +@pageBuilderAdvancedMenuText: @pageBuilderChromeText; +@pageBuilderAdvancedMenuTextActive: @pageBuilderChromeTextActive; +@pageBuilderAdvancedMenuWidth: 258px; + +@pageBuilderElementDropHighlight: #1D991D; +@pageBuilderElementHighlight: #3399FF; +@pageBuilderElementSelected: #33CC33; +@pageBuilderElementHighlightSub: #cccccc; +@pageBuilderElementSelectedSub: #999999; + +@dashboardMenuWidth: 200px; +@dashboardMenuBackground: #2b303b; diff --git a/config.js b/config.js new file mode 100644 index 000000000..8f4d1b2d2 --- /dev/null +++ b/config.js @@ -0,0 +1,5 @@ +import rc from 'rc'; + +export default rc('relax', { + port: 8080 +}); diff --git a/index.js b/index.js new file mode 100644 index 000000000..7770eb2fd --- /dev/null +++ b/index.js @@ -0,0 +1,2 @@ +require('babel/register'); +require('./app'); diff --git a/lib/client/actions/colors.js b/lib/client/actions/colors.js new file mode 100644 index 000000000..fef8bf812 --- /dev/null +++ b/lib/client/actions/colors.js @@ -0,0 +1,17 @@ +import {Actions} from 'relax-framework'; + +class ColorActions extends Actions { + init () { + + } + + getActions () { + return [ + 'add', + 'remove', + 'update' + ]; + } +} + +export default new ColorActions(); diff --git a/lib/client/actions/elements.js b/lib/client/actions/elements.js new file mode 100644 index 000000000..fc9d04a38 --- /dev/null +++ b/lib/client/actions/elements.js @@ -0,0 +1,15 @@ +import {Actions} from 'relax-framework'; + +class ElementsActions extends Actions { + init () { + + } + + getActions () { + return [ + 'getElements' + ]; + } +} + +export default new ElementsActions(); diff --git a/lib/client/actions/fonts.js b/lib/client/actions/fonts.js new file mode 100644 index 000000000..fd58e6c54 --- /dev/null +++ b/lib/client/actions/fonts.js @@ -0,0 +1,16 @@ +import {Actions} from 'relax-framework'; + +class FontsActions extends Actions { + init () { + + } + + getActions () { + return [ + 'submit', + 'remove' + ]; + } +} + +export default new FontsActions(); diff --git a/lib/client/actions/media.js b/lib/client/actions/media.js new file mode 100644 index 000000000..4c1838a98 --- /dev/null +++ b/lib/client/actions/media.js @@ -0,0 +1,19 @@ +import {Actions} from 'relax-framework'; + +class MediaActions extends Actions { + init () { + + } + + getActions () { + return [ + 'add', + 'remove', + 'removeBulk', + 'find', + 'resize' + ]; + } +} + +export default new MediaActions(); diff --git a/lib/client/actions/page.js b/lib/client/actions/page.js new file mode 100644 index 000000000..c50a50cea --- /dev/null +++ b/lib/client/actions/page.js @@ -0,0 +1,18 @@ +import {Actions} from 'relax-framework'; + +class PageActions extends Actions { + init () { + + } + + getActions () { + return [ + 'add', + 'remove', + 'validateSlug', + 'update' + ]; + } +} + +export default new PageActions(); diff --git a/lib/client/actions/schema-entries.js b/lib/client/actions/schema-entries.js new file mode 100644 index 000000000..5cdccbbbf --- /dev/null +++ b/lib/client/actions/schema-entries.js @@ -0,0 +1,27 @@ +import {Actions} from 'relax-framework'; + +class SchemaEntriesActions extends Actions { + init () { + + } + + getActions () { + return [ + 'add', + 'remove', + 'validateSlug', + 'update' + ]; + } +} + +var schemaEntriesActionsArr = {}; +export default (slug) => { + if(schemaEntriesActionsArr[slug]){ + return schemaEntriesActionsArr[slug]; + } else { + var actions = new SchemaEntriesActions(); + schemaEntriesActionsArr[slug] = actions; + return actions; + } +}; diff --git a/lib/client/actions/schema.js b/lib/client/actions/schema.js new file mode 100644 index 000000000..c5aa9416b --- /dev/null +++ b/lib/client/actions/schema.js @@ -0,0 +1,18 @@ +import {Actions} from 'relax-framework'; + +class SchemaActions extends Actions { + init () { + + } + + getActions () { + return [ + 'add', + 'remove', + 'validateSlug', + 'update' + ]; + } +} + +export default new SchemaActions(); diff --git a/lib/client/actions/settings.js b/lib/client/actions/settings.js new file mode 100644 index 000000000..023cb75b4 --- /dev/null +++ b/lib/client/actions/settings.js @@ -0,0 +1,15 @@ +import {Actions} from 'relax-framework'; + +class SettingsActions extends Actions { + init () { + + } + + getActions () { + return [ + 'saveSettings' + ]; + } +} + +export default new SettingsActions(); diff --git a/lib/client/actions/style.js b/lib/client/actions/style.js new file mode 100644 index 000000000..396dd993c --- /dev/null +++ b/lib/client/actions/style.js @@ -0,0 +1,17 @@ +import {Actions} from 'relax-framework'; + +class StyleActions extends Actions { + init () { + + } + + getActions () { + return [ + 'add', + 'remove', + 'update' + ]; + } +} + +export default new StyleActions(); diff --git a/lib/client/actions/tab.js b/lib/client/actions/tab.js new file mode 100644 index 000000000..d7871a141 --- /dev/null +++ b/lib/client/actions/tab.js @@ -0,0 +1,14 @@ +import {Actions} from 'relax-framework'; + +class TabActions extends Actions { + init () {} + + getActions () { + return [ + 'add', + 'remove' + ]; + } +} + +export default new TabActions(); diff --git a/lib/client/actions/user.js b/lib/client/actions/user.js new file mode 100644 index 000000000..0ca5030a1 --- /dev/null +++ b/lib/client/actions/user.js @@ -0,0 +1,17 @@ +import {Actions} from 'relax-framework'; + +class UserActions extends Actions { + init () { + + } + + getActions () { + return [ + 'add', + 'remove', + 'update' + ]; + } +} + +export default new UserActions(); diff --git a/lib/client/admin.js b/lib/client/admin.js new file mode 100644 index 000000000..92eb11b61 --- /dev/null +++ b/lib/client/admin.js @@ -0,0 +1,5 @@ +import {Router} from 'relax-framework'; +import adminRoutes from './routers/admin'; +import init from './init'; + +init(Router.extend(adminRoutes)); diff --git a/lib/client/auth.js b/lib/client/auth.js new file mode 100644 index 000000000..c87766e07 --- /dev/null +++ b/lib/client/auth.js @@ -0,0 +1,5 @@ +import {Router} from 'relax-framework'; +import authRoutes from './routers/auth'; +import init from './init'; + +init(Router.extend(authRoutes)); diff --git a/lib/client/collections/colors.js b/lib/client/collections/colors.js new file mode 100644 index 000000000..c14fd73b3 --- /dev/null +++ b/lib/client/collections/colors.js @@ -0,0 +1,7 @@ +import {Collection} from 'relax-framework'; +import ColorModel from '../models/color'; + +export default Collection.extend({ + model: ColorModel, + url: '/api/color' +}); diff --git a/lib/client/collections/media.js b/lib/client/collections/media.js new file mode 100644 index 000000000..6c6a27591 --- /dev/null +++ b/lib/client/collections/media.js @@ -0,0 +1,16 @@ +import {Collection} from 'relax-framework'; +import MediaModel from '../models/media'; +import Utils from '../../utils'; + +export default Collection.extend({ + model: MediaModel, + url: function () { + var url = '/api/media'; + + if (this.options) { + url = Utils.parseQueryUrl(url, this.options); + } + + return url; + } +}); diff --git a/lib/client/collections/pages.js b/lib/client/collections/pages.js new file mode 100644 index 000000000..f30075e97 --- /dev/null +++ b/lib/client/collections/pages.js @@ -0,0 +1,16 @@ +import {Collection} from 'relax-framework'; +import PageModel from '../models/page'; +import Utils from '../../utils'; + +export default Collection.extend({ + model: PageModel, + url: function () { + var url = '/api/page'; + + if (this.options) { + url = Utils.parseQueryUrl(url, this.options); + } + + return url; + } +}); diff --git a/lib/client/collections/schema-entries.js b/lib/client/collections/schema-entries.js new file mode 100644 index 000000000..d06b9d6bf --- /dev/null +++ b/lib/client/collections/schema-entries.js @@ -0,0 +1,20 @@ +import {Collection} from 'relax-framework'; +import SchemaEntryModel from '../models/schema-entry'; +import Utils from '../../utils'; + +export default Collection.extend({ + model: SchemaEntryModel, + initialize: function(models, options) { + this.slug = options.slug; + delete options.slug; + }, + url: function () { + var url = '/api/schema-entry/' + this.slug; + + if (this.options) { + url = Utils.parseQueryUrl(url, this.options); + } + + return url; + } +}); diff --git a/lib/client/collections/schemas.js b/lib/client/collections/schemas.js new file mode 100644 index 000000000..79d8d4d53 --- /dev/null +++ b/lib/client/collections/schemas.js @@ -0,0 +1,16 @@ +import {Collection} from 'relax-framework'; +import SchemaModel from '../models/schema'; +import Utils from '../../utils'; + +export default Collection.extend({ + model: SchemaModel, + url: function () { + var url = '/api/schema'; + + if (this.options) { + url = Utils.parseQueryUrl(url, this.options); + } + + return url; + } +}); diff --git a/lib/client/collections/settings.js b/lib/client/collections/settings.js new file mode 100644 index 000000000..03048d248 --- /dev/null +++ b/lib/client/collections/settings.js @@ -0,0 +1,16 @@ +import {Collection} from 'relax-framework'; +import SettingModel from '../models/setting'; + +export default Collection.extend({ + model: SettingModel, + url: function () { + const ids = this.options.ids; + var url = '/api/setting'; + + if (ids) { + url += '?ids=' + JSON.stringify(ids); + } + + return url; + } +}); diff --git a/lib/client/collections/styles.js b/lib/client/collections/styles.js new file mode 100644 index 000000000..bc2c681a2 --- /dev/null +++ b/lib/client/collections/styles.js @@ -0,0 +1,16 @@ +import {Collection} from 'relax-framework'; +import StyleModel from '../models/style'; +import Utils from '../../utils'; + +export default Collection.extend({ + model: StyleModel, + url: function () { + var url = '/api/style'; + + if (this.options) { + url = Utils.parseQueryUrl(url, this.options); + } + + return url; + } +}); diff --git a/lib/client/collections/tabs.js b/lib/client/collections/tabs.js new file mode 100644 index 000000000..344810dad --- /dev/null +++ b/lib/client/collections/tabs.js @@ -0,0 +1,15 @@ +import {Collection} from 'relax-framework'; +import TabModel from '../models/tab'; + +export default Collection.extend({ + model: TabModel, + url: function () { + var url = '/api/tab'; + + if (typeof this.options !== 'undefined' && this.options.user) { + url += '/'+this.options.user; + } + + return url; + } +}); diff --git a/lib/client/collections/users.js b/lib/client/collections/users.js new file mode 100644 index 000000000..1d887e477 --- /dev/null +++ b/lib/client/collections/users.js @@ -0,0 +1,7 @@ +import {Collection} from 'relax-framework'; +import UserModel from '../models/user'; + +export default Collection.extend({ + model: UserModel, + url: '/api/user' +}); diff --git a/lib/client/init.js b/lib/client/init.js new file mode 100644 index 000000000..0c76c5986 --- /dev/null +++ b/lib/client/init.js @@ -0,0 +1,21 @@ +import $ from 'jquery'; +import Backbone from 'backbone'; +Backbone.$ = $; + +import initStores from './stores'; + +export default function init (Router) { + window.initialProps = $('script[type="application/json"]').html(); + + if (window.initialProps) { + window.initialProps = JSON.parse(window.initialProps); + } + + initStores(window.initialProps); + + /* jshint ignore:start */ + new Router(); + /* jshint ignore:end */ + + Backbone.history.start({pushState: true}); +} diff --git a/lib/client/models/color.js b/lib/client/models/color.js new file mode 100644 index 000000000..565f24561 --- /dev/null +++ b/lib/client/models/color.js @@ -0,0 +1,6 @@ +import {Model} from 'relax-framework'; + +export default Model.extend({ + idAttribute: '_id', + urlRoot: '/api/color' +}); diff --git a/lib/client/models/media.js b/lib/client/models/media.js new file mode 100644 index 000000000..9b0d39c04 --- /dev/null +++ b/lib/client/models/media.js @@ -0,0 +1,8 @@ +import {Model} from 'relax-framework'; + +export default Model.extend({ + idAttribute: "_id", + url: function () { + return '/api/media/'+this.id; + } +}); diff --git a/lib/client/models/page.js b/lib/client/models/page.js new file mode 100644 index 000000000..192cc58ee --- /dev/null +++ b/lib/client/models/page.js @@ -0,0 +1,5 @@ +import {Model} from 'relax-framework'; + +export default Model.extend({ + idAttribute: "_id" +}); diff --git a/lib/client/models/schema-entry.js b/lib/client/models/schema-entry.js new file mode 100644 index 000000000..192cc58ee --- /dev/null +++ b/lib/client/models/schema-entry.js @@ -0,0 +1,5 @@ +import {Model} from 'relax-framework'; + +export default Model.extend({ + idAttribute: "_id" +}); diff --git a/lib/client/models/schema.js b/lib/client/models/schema.js new file mode 100644 index 000000000..2aa7d8e9a --- /dev/null +++ b/lib/client/models/schema.js @@ -0,0 +1,12 @@ +import {Model} from 'relax-framework'; + +export default Model.extend({ + idAttribute: "_id", + url: function () { + if (this.id) { + return '/api/schema/'+this.id; + } else { + return '/api/schema'; + } + } +}); diff --git a/lib/client/models/setting.js b/lib/client/models/setting.js new file mode 100644 index 000000000..42f2fd61e --- /dev/null +++ b/lib/client/models/setting.js @@ -0,0 +1,12 @@ +import {Model} from 'relax-framework'; + +export default Model.extend({ + idAttribute: "_id", + url: function () { + if (this.id) { + return '/api/setting/'+this.id; + } else { + return '/api/setting'; + } + } +}); diff --git a/lib/client/models/style.js b/lib/client/models/style.js new file mode 100644 index 000000000..be84b8a34 --- /dev/null +++ b/lib/client/models/style.js @@ -0,0 +1,12 @@ +import {Model} from 'relax-framework'; + +export default Model.extend({ + idAttribute: "_id", + url: function () { + if (this.id) { + return '/api/style/'+this.id; + } else { + return '/api/style'; + } + } +}); diff --git a/lib/client/models/tab.js b/lib/client/models/tab.js new file mode 100644 index 000000000..192cc58ee --- /dev/null +++ b/lib/client/models/tab.js @@ -0,0 +1,5 @@ +import {Model} from 'relax-framework'; + +export default Model.extend({ + idAttribute: "_id" +}); diff --git a/lib/client/models/user.js b/lib/client/models/user.js new file mode 100644 index 000000000..192cc58ee --- /dev/null +++ b/lib/client/models/user.js @@ -0,0 +1,5 @@ +import {Model} from 'relax-framework'; + +export default Model.extend({ + idAttribute: "_id" +}); diff --git a/lib/client/public.js b/lib/client/public.js new file mode 100644 index 000000000..93487ed91 --- /dev/null +++ b/lib/client/public.js @@ -0,0 +1,5 @@ +import {Router} from 'relax-framework'; +import publicRoutes from './routers/public'; +import init from './init'; + +init(Router.extend(publicRoutes)); diff --git a/lib/client/routers/admin.js b/lib/client/routers/admin.js new file mode 100644 index 000000000..480fc4627 --- /dev/null +++ b/lib/client/routers/admin.js @@ -0,0 +1,282 @@ +import Cortex from 'backbone-cortex'; +import Admin from '../../components/admin'; +import Q from 'q'; +import merge from 'lodash.merge'; +import forEach from 'lodash.foreach'; +import {Router} from 'relax-framework'; + +import sessionStore from '../stores/session'; +import usersStore from '../stores/users'; +import pagesStore from '../stores/pages'; +import elementsStore from '../stores/elements'; +import mediaStore from '../stores/media'; +import settingsStore from '../stores/settings'; +import colorsStore from '../stores/colors'; +import schemasStore from '../stores/schemas'; +import schemaEntriesStoreFactory from '../stores/schema-entries'; +import tabsStore from '../stores/tabs'; + +import generalSettingsIds from '../../settings/general'; +import fontSettingsIds from '../../settings/fonts'; + +var cortex = new Cortex(); + +function renderComponent (Component, route, params) { + Router.prototype.renderComponent(Component, merge(route.data, params)); +} + +cortex.use((route, next) => { + Q() + .then(() => sessionStore.getSession()) + .then((user) => { + route.data.user = user; + route.data.tabs = []; + + tabsStore + .findAll({ + user: user._id + }) + .then((tabs) => { + route.data.tabs = tabs; + }) + .fin(next); + }) + .catch((err) => { + window.location.href = '/admin/login'; + }); +}); + +cortex.route('admin', (route, next) => { + settingsStore + .findByIds(generalSettingsIds) + .then((settings) => { + renderComponent(Admin, route, { + activePanelType: 'settings', + settings + }); + }) + .done(); +}); + +cortex.route('admin/pages', (route, next) => { + var query = route.query || {}; + + pagesStore + .findAll(query) + .then((pages) => { + renderComponent(Admin, route, { + activePanelType: 'pages', + pages, + query + }); + }) + .done(); +}); + +cortex.route('admin/media', (route, next) => { + var query = route.query || {}; + + mediaStore + .findAll(query) + .then((media) => { + renderComponent(Admin, route, { + activePanelType: 'media', + media, + query + }); + }) + .done(); +}); + +cortex.route('admin/fonts', (route, next) => { + settingsStore + .findByIds(fontSettingsIds) + .then((settings) => { + renderComponent(Admin, route, { + activePanelType: 'fonts', + settings + }); + }) + .done(); +}); + +cortex.route('admin/colors', (route, next) => { + colorsStore + .findAll() + .then((colors) => { + renderComponent(Admin, route, { + activePanelType: 'colors', + colors + }); + }) + .done(); +}); + +cortex.route('admin/schemas/new', (route, next) => { + renderComponent(Admin, route, { + activePanelType: 'schemasNew', + breadcrumbs: [ + { + label: 'Schemas', + type: 'schemas', + link: '/admin/schemas' + }, + { + label: 'New' + } + ] + }); +}); + +cortex.route('admin/schemas/:slug/:entrySlug', (route, next) => { + var schemaEntriesStore = schemaEntriesStoreFactory(route.params.slug); + + Q + .all([ + schemaEntriesStore.findBySlug(route.params.entrySlug), + schemasStore.findBySlug(route.params.slug) + ]) + .spread((schemaEntry, schema) => { + renderComponent(Admin, route, { + activePanelType: 'schemaEntry', + schemaEntry, + schema, + breadcrumbs: [ + { + label: 'Schemas', + type: 'schemas', + link: '/admin/schemas' + }, + { + label: schema.title, + link: '/admin/schemas/'+schema.slug + }, + { + label: schemaEntry.title + } + ] + }); + }) + .done(); +}); + +cortex.route('admin/schemas/:slug', (route, next) => { + var schemaEntriesStore = schemaEntriesStoreFactory(route.params.slug); + var query = route.query || {}; + + Q + .all([ + schemaEntriesStore.findAll(query), + schemasStore.findBySlug(route.params.slug) + ]) + .spread((schemaEntries, schema) => { + renderComponent(Admin, route, { + activePanelType: 'schema', + schemaEntries, + schema, + query, + breadcrumbs: [ + { + label: 'Schemas', + type: 'schemas', + link: '/admin/schemas' + }, + { + label: schema.title + } + ] + }); + }) + .done(); +}); + +cortex.route('admin/schemas', (route, next) => { + var query = route.query || {}; + schemasStore + .findAll(query) + .then((schemas) => { + renderComponent(Admin, route, { + activePanelType: 'schemas', + schemas, + query + }); + }) + .done(); +}); + +cortex.route('admin/users', (route, next) => { + var query = route.query || {}; + + usersStore + .findAll(query) + .then((users) => { + renderComponent(Admin, route, { + activePanelType: 'users', + users, + query + }); + }) + .done(); +}); + +cortex.route('admin/users/:username', (route, next) => { + Q() + .then(() => usersStore.findOne({username: route.params.username})) + .then((editUser) => { + renderComponent(Admin, route, { + activePanelType: 'userEdit', + editUser, + breadcrumbs: [ + { + label: 'Users', + type: 'users', + link: '/admin/users' + }, + { + label: editUser.name + } + ] + }); + }) + .catch((error) => { + + }); +}); + +cortex.route('admin/page/:slug', (route, next) => { + Q() + .then(() => pagesStore.findBySlug(route.params.slug)) + .then((page) => Q.all([page, elementsStore.findAll()])) + .spread((page, elements) => Q.all([page, elements, colorsStore.findAll()])) + .spread((page, elements, colors) => { + + var inTabs = false; + forEach(route.data.tabs, (tab) => { + if (tab.pageId._id === page._id) { + inTabs = true; + return false; + } + }); + + if (!inTabs) { + tabsStore.add({ + pageId: page._id, + userId: route.data.user._id + }); + } + + renderComponent(Admin, route, { + activePanelType: 'page', + elements, + page, + colors + }); + }) + .catch((error) => { + + }); +}); + +export default { + routes: cortex.getRoutes() +}; diff --git a/lib/client/routers/auth.js b/lib/client/routers/auth.js new file mode 100644 index 000000000..543d66e22 --- /dev/null +++ b/lib/client/routers/auth.js @@ -0,0 +1,20 @@ +import Cortex from 'backbone-cortex'; +import {Router} from 'relax-framework'; + +import Init from '../../components/admin/init'; +import Login from '../../components/admin/login'; + +var cortex = new Cortex(); +var renderComponent = Router.prototype.renderComponent.bind(Router.prototype); + +cortex.route('admin/init', (route, next) => { + renderComponent(Init, {}); +}); + +cortex.route('admin/login', (route, next) => { + renderComponent(Login, {}); +}); + +export default { + routes: cortex.getRoutes() +}; diff --git a/lib/client/routers/public.js b/lib/client/routers/public.js new file mode 100644 index 000000000..fb109e77b --- /dev/null +++ b/lib/client/routers/public.js @@ -0,0 +1,21 @@ +import Page from '../../components/page'; +import elementsStore from '../stores/elements'; +import pagesStore from '../stores/pages'; +import Q from 'q'; + +export default { + routes: { + ':slug': 'page' + }, + page: function (slug) { + Q() + .then(() => pagesStore.findBySlug(slug)) + .then((page) => Q.all([page, elementsStore.findAll()])) + .spread((page, elements) => { + this.renderComponent(Page, {elements, page}); + }) + .catch((error) => { + console.log('Error loading page: '+error); + }); + } +}; diff --git a/lib/client/stores/colors.js b/lib/client/stores/colors.js new file mode 100644 index 000000000..3a51fc05c --- /dev/null +++ b/lib/client/stores/colors.js @@ -0,0 +1,24 @@ +import {ClientStore} from 'relax-framework'; +import ColorsCollection from '../collections/colors'; +import colorActions from '../actions/colors'; + +class ColorsStore extends ClientStore { + constructor () { + super(); + } + + init () { + if (this.isClient()) { + this.listenTo(colorActions, 'add', this.add); + this.listenTo(colorActions, 'remove', this.remove); + this.listenTo(colorActions, 'update', this.update); + } + } + + createCollection () { + return new ColorsCollection(); + } + +} + +export default new ColorsStore(); diff --git a/lib/client/stores/elements.js b/lib/client/stores/elements.js new file mode 100644 index 000000000..aa968d3f1 --- /dev/null +++ b/lib/client/stores/elements.js @@ -0,0 +1,16 @@ +import {ClientStore} from 'relax-framework'; +import Q from 'q'; +import elements from '../../components/elements'; + +class ElementsStore extends ClientStore { + + findAll () { + return Q() + .then(() => { + return elements; + }); + } + +} + +export default new ElementsStore(); diff --git a/lib/client/stores/fonts.js b/lib/client/stores/fonts.js new file mode 100644 index 000000000..37942508c --- /dev/null +++ b/lib/client/stores/fonts.js @@ -0,0 +1,73 @@ +import {ClientStore} from 'relax-framework'; +import Q from 'q'; +import fontsActions from '../actions/fonts'; +import $ from 'jquery'; + +class FontsStore extends ClientStore { + + constructor () { + super(); + } + + init () { + if (this.isClient()) { + this.listenTo(fontsActions, 'submit', this.onSubmit); + this.listenTo(fontsActions, 'remove', this.onRemove); + } + } + + onSubmit (files, deferred) { + this.runPromises(deferred, [ + this.submit(files) + ]); + } + + onRemove (id, deferred) { + this.runPromises(deferred, [ + this.remove(id) + ]); + } + + submit (files) { + return () => { + return Q() + .then(() => { + var deferred = Q.defer(); + + $ + .post('/api/fonts/submit', {data: JSON.stringify(files)}) + .done((response) => { + deferred.resolve(response); + }) + .fail((error) => { + deferred.error(error); + }); + + return deferred.promise; + }); + }; + } + + remove (id) { + return () => { + return Q() + .then(() => { + var deferred = Q.defer(); + + $ + .post('/api/fonts/remove', {id}) + .done((response) => { + deferred.resolve(response); + }) + .fail((error) => { + deferred.error(error); + }); + + return deferred.promise; + }); + }; + } + +} + +export default new FontsStore(); diff --git a/lib/client/stores/index.js b/lib/client/stores/index.js new file mode 100644 index 000000000..0d1b09c25 --- /dev/null +++ b/lib/client/stores/index.js @@ -0,0 +1,49 @@ +import forEach from 'lodash.foreach'; + +import colors from './colors'; +import schemaEntries from './schema-entries'; +import elements from './elements'; +import fonts from './fonts'; +import media from './media'; +import pages from './pages'; +import schemas from './schemas'; +import settings from './settings'; +import users from './users'; +import session from './session'; +import tabs from './tabs'; + +var stores = { + colors, + schemaEntries, + elements, + fonts, + media, + pages, + schemas, + settings, + users, + session, + tabs +}; + +export { + colors, + schemaEntries, + elements, + fonts, + media, + pages, + schemas, + settings, + users, + session, + tabs +}; + +export default function initStore (data) { + forEach(stores, (store, key) => { + if (data[key]) { + store.data = data[key]; + } + }); +} diff --git a/lib/client/stores/media.js b/lib/client/stores/media.js new file mode 100644 index 000000000..0616c0535 --- /dev/null +++ b/lib/client/stores/media.js @@ -0,0 +1,57 @@ +import {ClientStore} from 'relax-framework'; +import MediaCollection from '../collections/media'; +import mediaActions from '../actions/media'; +import forEach from 'lodash.foreach'; +import Q from 'q'; +import $ from 'jquery'; + +class MediaStore extends ClientStore { + constructor () { + super(); + } + + init () { + if (this.isClient()) { + this.listenTo(mediaActions, 'add', this.add); + this.listenTo(mediaActions, 'remove', this.remove); + this.listenTo(mediaActions, 'removeBulk', this.removeBulk); + this.listenTo(mediaActions, 'find', this.findById); + this.listenTo(mediaActions, 'resize', this.resize); + } + } + + createCollection () { + return new MediaCollection(); + } + + removeBulk (ids) { + var promises = []; + + forEach(ids, (id) => { + promises.push(this.remove(id)); + }); + + return Q.all(promises); + } + + resize (data) { + return Q() + .then(() => { + var deferred = Q.defer(); + + $ + .get('/api/media/resize', data) + .done((response) => { + this.getModel(data.id).set(response); + this.trigger('update', this.collection.toJSON()); + }) + .fail((error) => { + deferred.reject(error); + }); + + return deferred.promise; + }); + } +} + +export default new MediaStore(); diff --git a/lib/client/stores/pages.js b/lib/client/stores/pages.js new file mode 100644 index 000000000..3266c7330 --- /dev/null +++ b/lib/client/stores/pages.js @@ -0,0 +1,57 @@ +import {ClientStore} from 'relax-framework'; +import PagesCollection from '../collections/pages'; +import pageActions from '../actions/page'; +import $ from 'jquery'; +import Q from 'q'; +import tabsStore from './tabs'; + +class PagesStore extends ClientStore { + constructor () { + super(); + } + + init () { + if (this.isClient()) { + this.listenTo(pageActions, 'add', this.add); + this.listenTo(pageActions, 'remove', this.remove); + this.listenTo(pageActions, 'validateSlug', this.validateSlug); + this.listenTo(pageActions, 'update', this.update); + } + } + + createCollection () { + var collection = new PagesCollection(); + + collection.on('remove', this.onRemove.bind(this)); + + return collection; + } + + onRemove () { + tabsStore.fetchCollection(); + } + + validateSlug(slug, deferred) { + return Q() + .then(() => { + var deferred = Q.defer(); + + $ + .get('/api/page/slug/'+slug) + .done((response) => { + deferred.resolve(response.count > 0); + }) + .fail((error) => { + deferred.reject(error); + }); + + return deferred.promise; + }); + } + + findBySlug (slug) { + return this.findOne({slug}); + } +} + +export default new PagesStore(); diff --git a/lib/client/stores/schema-entries.js b/lib/client/stores/schema-entries.js new file mode 100644 index 000000000..2c758b649 --- /dev/null +++ b/lib/client/stores/schema-entries.js @@ -0,0 +1,61 @@ +import {ClientStore} from 'relax-framework'; +import SchemaEntriesCollection from '../collections/schema-entries'; +import schemaEntriesActionsFactory from '../actions/schema-entries'; +import $ from 'jquery'; +import Q from 'q'; + +class SchemaEntriesStore extends ClientStore { + constructor (slug) { + this.slug = slug; + this.schemaEntriesActions = schemaEntriesActionsFactory(slug); + super(); + } + + init () { + if (this.isClient()) { + this.listenTo(this.schemaEntriesActions, 'add', this.add); + this.listenTo(this.schemaEntriesActions, 'remove', this.remove); + this.listenTo(this.schemaEntriesActions, 'validateSlug', this.validateSlug); + this.listenTo(this.schemaEntriesActions, 'update', this.update); + } + } + + createCollection () { + return new SchemaEntriesCollection([], { + slug: this.slug + }); + } + + validateSlug(slug) { + return Q() + .then(() => { + var deferred = Q.defer(); + + $ + .get('/api/schema-entry/'+this.slug+'/slug/'+slug) + .done((response) => { + deferred.resolve(response.count > 0); + }) + .fail((error) => { + deferred.error(error); + }); + + return deferred.promise; + }); + } + + findBySlug (slug) { + return this.findOne({slug}); + } +} + +var schemaEntriesStores = {}; +export default (slug) => { + if(schemaEntriesStores[slug]){ + return schemaEntriesStores[slug]; + } else { + var store = new SchemaEntriesStore(slug); + schemaEntriesStores[slug] = store; + return store; + } +}; diff --git a/lib/client/stores/schemas.js b/lib/client/stores/schemas.js new file mode 100644 index 000000000..bb618c933 --- /dev/null +++ b/lib/client/stores/schemas.js @@ -0,0 +1,48 @@ +import {ClientStore} from 'relax-framework'; +import SchemasCollection from '../collections/schemas'; +import schemaActions from '../actions/schema'; +import $ from 'jquery'; +import Q from 'q'; + +class SchemasStore extends ClientStore { + constructor () { + super(); + } + + init () { + if (this.isClient()) { + this.listenTo(schemaActions, 'add', this.add); + this.listenTo(schemaActions, 'remove', this.remove); + this.listenTo(schemaActions, 'validateSlug', this.validateSlug); + this.listenTo(schemaActions, 'update', this.update); + } + } + + createCollection () { + return new SchemasCollection(); + } + + validateSlug(slug) { + return Q() + .then(() => { + var deferred = Q.defer(); + + $ + .get('/api/schema/slug/'+slug) + .done((response) => { + deferred.resolve(response.count > 0); + }) + .fail((error) => { + deferred.error(error); + }); + + return deferred.promise; + }); + } + + findBySlug (slug) { + return this.findOne({slug}); + } +} + +export default new SchemasStore(); diff --git a/lib/client/stores/session.js b/lib/client/stores/session.js new file mode 100644 index 000000000..ace421f0a --- /dev/null +++ b/lib/client/stores/session.js @@ -0,0 +1,28 @@ +import $ from 'jquery'; +import Q from 'q'; + +class SessionStore { + getSession () { + return Q() + .then(() => { + var deferred = Q.defer(); + + $ + .get('/api/session') + .done((response) => { + if (response) { + deferred.resolve(response); + } else { + deferred.reject(); + } + }) + .fail((error) => { + deferred.reject(error); + }); + + return deferred.promise; + }); + } +} + +export default new SessionStore(); diff --git a/lib/client/stores/settings.js b/lib/client/stores/settings.js new file mode 100644 index 000000000..4b5707ec1 --- /dev/null +++ b/lib/client/stores/settings.js @@ -0,0 +1,78 @@ +import every from 'lodash.every'; +import forEach from 'lodash.foreach'; +import {ClientStore} from 'relax-framework'; +import SettingsCollection from '../collections/settings'; +import settingActions from '../actions/settings'; +import Q from 'q'; + +class SettingsStore extends ClientStore { + constructor () { + super(); + } + + init () { + if (this.isClient()) { + this.listenTo(settingActions, 'saveSettings', this.saveSettings); + } + } + + createCollection () { + return new SettingsCollection([], { + ids: [] + }); + } + + saveSettings(settings) { + var collection = this.getCollection(); + + var promises = [], optionsIds = false; + + if (collection.options.ids) { + optionsIds = collection.options.ids; + delete collection.options.ids; + } + + forEach(settings, (value, key) => { + promises.push(collection.createOrUpdate({_id: key, value})); + }); + + return Q() + .all(promises) + .then(() => { + var json = this.collection.toJSON(); + this.trigger('update', json); + return json; + }) + .catch((error) => { + this.trigger('error', error); + }) + .fin(() => { + if (optionsIds) { + collection.options.ids = optionsIds; + } + }); + } + + findByIds (settingsIds) { + return Q() + .then(() => this.getCollectionAsync({ids: settingsIds})) + .then((collection) => { + var result; + + if (!every(settingsIds, (settingId) => collection.get(settingId))) { + collection.options.ids = settingsIds; + result = Q() + .then(() => this.fetchCollection()) + .then(() => { + return collection.toJSON(); + }); + } else { + result = Q().then(() => collection.toJSON()); + } + + return result; + }); + } +} + +export default new SettingsStore(); diff --git a/lib/client/stores/styles.js b/lib/client/stores/styles.js new file mode 100644 index 000000000..e7aad4921 --- /dev/null +++ b/lib/client/stores/styles.js @@ -0,0 +1,24 @@ +import {ClientStore} from 'relax-framework'; +import StylesCollection from '../collections/styles'; +import styleActions from '../actions/style'; + +class StylesStore extends ClientStore { + constructor () { + super(); + } + + init () { + if (this.isClient()) { + this.listenTo(styleActions, 'add', this.add); + this.listenTo(styleActions, 'remove', this.remove); + this.listenTo(styleActions, 'update', this.update); + } + } + + createCollection () { + return new StylesCollection(); + } + +} + +export default new StylesStore(); diff --git a/lib/client/stores/tabs.js b/lib/client/stores/tabs.js new file mode 100644 index 000000000..59fa6faf3 --- /dev/null +++ b/lib/client/stores/tabs.js @@ -0,0 +1,22 @@ +import {ClientStore} from 'relax-framework'; +import TabsCollection from '../collections/tabs'; +import tabActions from '../actions/tab'; + +class TabsStore extends ClientStore { + constructor () { + super(); + } + + init () { + if (this.isClient()) { + this.listenTo(tabActions, 'add', this.add); + this.listenTo(tabActions, 'remove', this.remove); + } + } + + createCollection () { + return new TabsCollection(); + } +} + +export default new TabsStore(); diff --git a/lib/client/stores/users.js b/lib/client/stores/users.js new file mode 100644 index 000000000..50b6dc51b --- /dev/null +++ b/lib/client/stores/users.js @@ -0,0 +1,23 @@ +import {ClientStore} from 'relax-framework'; +import UsersCollection from '../collections/users'; +import userActions from '../actions/user'; + +class UsersStore extends ClientStore { + constructor () { + super(); + } + + init () { + if (this.isClient()) { + this.listenTo(userActions, 'add', this.add); + this.listenTo(userActions, 'remove', this.remove); + this.listenTo(userActions, 'update', this.update); + } + } + + createCollection () { + return new UsersCollection(); + } +} + +export default new UsersStore(); diff --git a/lib/colors/index.js b/lib/colors/index.js new file mode 100644 index 000000000..f1e23932f --- /dev/null +++ b/lib/colors/index.js @@ -0,0 +1,71 @@ +import merge from 'lodash.merge'; +import {Events} from 'backbone'; +import Colr from 'colr'; + +import colorsStore from '../client/stores/colors'; + +class ColorsManager { + constructor () { + if (this.isClient()) { + var collection = colorsStore.getCollection(); + this.listenTo(collection, 'update change', this.onUpdate.bind(this)); + } + } + + isClient () { + return typeof document !== 'undefined'; + } + + onUpdate () { + this.trigger('update'); + } + + getColor (colorObj) { + if (typeof colorObj === 'object') { + var hex = '#000000'; + var opacity = colorObj.opacity; + var label = 'Custom'; + + if (colorObj.type === 'palette') { + const collection = colorsStore.getCollection({fetch: false}); + var model = collection.get(colorObj.value); + + if (model) { + var json = model.toJSON(); + hex = json.value; + label = json.label; + } + } else { + var isOk = /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(colorObj.value); + hex = isOk ? colorObj.value : '#000000'; + } + + return { + colr: Colr().fromHex(hex), + opacity: opacity, + label + }; + } + return { + colr: Colr().fromHex('#000000'), + opacity: 100, + label: 'Custom' + }; + } + + getColorString (colorObj) { + var color = (colorObj && colorObj.colr) ? colorObj : this.getColor(colorObj); + if (color) { + if (color.opacity === 100) { + return color.colr.toHex(); + } else { + var rgb = color.colr.toRgbObject(); + return 'rgba('+rgb.r+', '+rgb.g+', '+rgb.b+', '+(color.opacity/100)+')'; + } + } + return '#000000'; + } +} +merge(ColorsManager.prototype, Events); + +export default new ColorsManager(); diff --git a/lib/components/a.jsx b/lib/components/a.jsx new file mode 100644 index 000000000..93db983d9 --- /dev/null +++ b/lib/components/a.jsx @@ -0,0 +1,24 @@ +import React from 'react'; +import {Component, Router} from 'relax-framework'; + +export default class A extends Component { + onClick (event) { + var url = this.props.href; + if (url && url.charAt(0) === '/') { + event.preventDefault(); + Router.prototype.navigate(url, {trigger: true}); + } + + if (this.props.afterClick) { + this.props.afterClick(); + } + } + + render () { + return ( + + {this.props.children} + + ); + } +} diff --git a/lib/components/active-panel.jsx b/lib/components/active-panel.jsx new file mode 100644 index 000000000..e1339aa3d --- /dev/null +++ b/lib/components/active-panel.jsx @@ -0,0 +1,16 @@ +import React from 'react'; +import {Component} from 'relax-framework'; + +export default class ActivePanel extends Component { + render () { + return ( +
+ {this.context.activePanel} +
+ ); + } +} + +ActivePanel.contextTypes = { + activePanel: React.PropTypes.any +}; diff --git a/lib/components/admin/index.jsx b/lib/components/admin/index.jsx new file mode 100644 index 000000000..40c7e2e81 --- /dev/null +++ b/lib/components/admin/index.jsx @@ -0,0 +1,166 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import TopMenu from './top-menu'; +import MenuBar from './menu-bar'; +import Backbone from 'backbone'; + +import panels from './panels'; +import Overlay from '../overlay'; + +export default class Admin extends Component { + + getInitialState () { + this.changeDisplayBind = this.changeDisplay.bind(this); + this.previewToggleBind = this.previewToggle.bind(this); + this.addOverlayBind = this.addOverlay.bind(this); + this.closeOverlayBind = this.closeOverlay.bind(this); + + return { + display: 'desktop', + editing: true, + lastDashboard: '/admin', + overlay: false + }; + } + + componentWillReceiveProps (nextProps) { + if (!nextProps.page) { + this.updateLastDashboardPage(); + } + } + + componentDidUpdate (prevProps, prevState) { + if (prevState.display !== this.state.display) { + /* jshint ignore:start */ + window.dispatchEvent(new Event('resize')); + /* jshint ignore:end */ + } + } + + getChildContext () { + return { + breadcrumbs: this.props.breadcrumbs, + pages: this.props.pages, + page: this.props.page, + elements: this.props.elements, + media: this.props.media, + settings: this.props.settings, + colors: this.props.colors, + schemas: this.props.schemas, + schema: this.props.schema, + schemaEntries: this.props.schemaEntries, + schemaEntry: this.props.schemaEntry, + query: this.props.query, + activePanelType: this.props.activePanelType, + display: this.state.display, + changeDisplay: this.changeDisplayBind, + editing: this.state.editing, + previewToggle: this.previewToggleBind, + user: this.props.user, + users: this.props.users, + editUser: this.props.editUser, + tabs: this.props.tabs, + lastDashboard: this.state.lastDashboard, + addOverlay: this.addOverlayBind, + closeOverlay: this.closeOverlayBind + }; + } + + updateLastDashboardPage () { + this.setState({ + lastDashboard: '/' + Backbone.history.getFragment() + }); + } + + changeDisplay (display) { + this.setState({ + display + }); + } + + previewToggle () { + this.setState({ + editing: !this.state.editing + }); + } + + addOverlay (overlay) { + this.setState({ + overlay + }); + } + + closeOverlay () { + this.setState({ + overlay: false + }); + } + + renderActivePanel () { + if (this.props.activePanelType && panels[this.props.activePanelType]) { + let Panel = panels[this.props.activePanelType]; + return ( + + ); + } + } + + renderOverlay () { + if (this.state.overlay !== false) { + return ( + + {React.cloneElement(this.state.overlay, {onClose: this.closeOverlayBind})} + + ); + } + } + + render () { + return ( +
+ +
+ {!this.props.page && } +
+ {this.renderActivePanel()} +
+
+ {this.renderOverlay()} +
+ ); + } +} + +Admin.propTypes = { + activePanelType: React.PropTypes.string, + breadcrumbs: React.PropTypes.array, + user: React.PropTypes.object, + users: React.PropTypes.array +}; + +Admin.childContextTypes = { + breadcrumbs: React.PropTypes.array, + pages: React.PropTypes.array, + page: React.PropTypes.object, + elements: React.PropTypes.object, + media: React.PropTypes.array, + settings: React.PropTypes.array, + colors: React.PropTypes.array, + schemas: React.PropTypes.array, + schema: React.PropTypes.object, + schemaEntries: React.PropTypes.array, + schemaEntry: React.PropTypes.object, + query: React.PropTypes.object, + activePanelType: React.PropTypes.string, + display: React.PropTypes.string.isRequired, + changeDisplay: React.PropTypes.func.isRequired, + editing: React.PropTypes.bool.isRequired, + previewToggle: React.PropTypes.func.isRequired, + user: React.PropTypes.object.isRequired, + users: React.PropTypes.array, + editUser: React.PropTypes.object, + tabs: React.PropTypes.array, + lastDashboard: React.PropTypes.string, + addOverlay: React.PropTypes.func, + closeOverlay: React.PropTypes.func +}; diff --git a/lib/components/admin/init.jsx b/lib/components/admin/init.jsx new file mode 100644 index 000000000..51a205c5f --- /dev/null +++ b/lib/components/admin/init.jsx @@ -0,0 +1,73 @@ +import React from 'react'; +import {Component, Router} from 'relax-framework'; +import OptionsList from '../options-list'; +import {Types} from '../../types'; + +import usersActions from '../../client/actions/user'; + +export default class Init extends Component { + getInitialState () { + return { + user: { + username: '', + name: '', + password: '', + email: '' + } + }; + } + + onChange (id, value) { + this.state.user[id] = value; + this.setState({ + user: this.state.user + }); + } + + onSubmit (event) { + event.preventDefault(); + + usersActions + .add(this.state.user) + .then(() => { + Router.prototype.navigate('/admin/login', {trigger: true}); + }); + } + + render () { + return ( +
+

Welcome
to Relax

+ + All done! +
+ ); + } +} + +Init.options = [ + { + label: 'Username', + type: Types.String, + id: 'username', + default: '' + }, + { + label: 'Password', + type: Types.String, + id: 'password', + default: '' + }, + { + label: 'Name', + type: Types.String, + id: 'name', + default: '' + }, + { + label: 'Email', + type: Types.String, + id: 'email', + default: '' + } +]; diff --git a/lib/components/admin/login.jsx b/lib/components/admin/login.jsx new file mode 100644 index 000000000..d37e0cd21 --- /dev/null +++ b/lib/components/admin/login.jsx @@ -0,0 +1,50 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import {Types} from '../../types'; + +export default class Login extends Component { + + onSubmit (event) { + event.preventDefault(); + React.findDOMNode(this.refs.form).submit(); + } + + render () { + return ( +
+

Login

+
+
+
Username
+
+ +
+
+
+
Password
+
+ +
+
+ Login + +
+
+ ); + } +} + +Login.options = [ + { + label: 'Username', + type: Types.String, + id: 'username', + default: '' + }, + { + label: 'Password', + type: Types.String, + id: 'password', + default: '' + } +]; diff --git a/lib/components/admin/menu-bar.jsx b/lib/components/admin/menu-bar.jsx new file mode 100644 index 000000000..ced16ea65 --- /dev/null +++ b/lib/components/admin/menu-bar.jsx @@ -0,0 +1,129 @@ +import A from '../a'; +import React from 'react'; +import {Component} from 'relax-framework'; +import cx from 'classnames'; +import Utils from '../../utils'; + +export default class MenuBar extends Component { + getInitialState () { + return { + userOpened: false + }; + } + + toggleUser () { + this.setState({ + userOpened: !this.state.userOpened + }); + } + + renderLink (link) { + let active = this.context.activePanelType === link.type || (this.context.breadcrumbs && this.context.breadcrumbs.length > 0 && this.context.breadcrumbs[0].type === link.type); + + return ( +
  • + {link.label} +
  • + ); + } + + renderOpenedUser () { + if (this.state.userOpened) { + const editLink = '/admin/users/' + this.context.user.username; + return ( + + ); + } + } + + renderUser () { + if (this.context.user) { + var url = Utils.getGravatarImage(this.context.user.email, 25); + return ( +
    +
    + +
    + {this.context.user.name} +
    + {this.state.userOpened ? 'arrow_drop_down' : 'arrow_drop_up'} + {this.renderOpenedUser()} +
    +
    + ); + } + } + + render () { + var links = [ + { + type: 'settings', + link: '/admin', + label: 'General Settings' + }, + { + type: 'pages', + link: '/admin/pages', + label: 'Pages' + }, + { + type: 'media', + link: '/admin/media', + label: 'Media' + }, + { + type: 'fonts', + link: '/admin/fonts', + label: 'Fonts' + }, + { + type: 'colors', + link: '/admin/colors', + label: 'Colors' + }, + { + type: 'schemas', + link: '/admin/schemas', + label: 'Schemas' + }, + { + type: 'users', + link: '/admin/users', + label: 'Users' + } + ]; + + return ( + + ); + } +} + +MenuBar.propTypes = { +}; + +MenuBar.contextTypes = { + activePanelType: React.PropTypes.string, + breadcrumbs: React.PropTypes.any, + user: React.PropTypes.object +}; diff --git a/lib/components/admin/panels/colors/color.jsx b/lib/components/admin/panels/colors/color.jsx new file mode 100644 index 000000000..7573ef1a7 --- /dev/null +++ b/lib/components/admin/panels/colors/color.jsx @@ -0,0 +1,102 @@ +import {Component} from 'relax-framework'; +import React from 'react'; +import cloneDeep from 'lodash.clonedeep'; +import Lightbox from '../../../lightbox'; + +import colorActions from '../../../../client/actions/colors'; + +export default class Color extends Component { + getInitialState () { + return { + removing: false + }; + } + + onEdit (event) { + event.preventDefault(); + this.props.onEdit(cloneDeep(this.props.color)); + } + + onRemove (event) { + event.preventDefault(); + this.setState({ + removing: true + }); + } + + cancelRemove (event) { + event.preventDefault(); + this.setState({ + removing: false + }); + } + + confirmRemove (event) { + event.preventDefault(); + colorActions.remove(this.props.color._id); + this.setState({ + removing: false + }); + } + + onDuplicate (event) { + event.preventDefault(); + var cloneColor = cloneDeep(this.props.color); + delete cloneColor._id; + colorActions.add(cloneColor); + } + + renderRemoving () { + if (this.state.removing) { + const label = 'Are you sure you want to remove the color '+this.props.color.label+' from your colors palette?'; + const label1 = 'Every component in your pages using this color will loose the link to it! Notice you can change its value and label to customize and not lose the link.'; + return ( + +
    {label}
    +
    {label1}
    + +
    + ); + } + } + + render () { + var colorStyle = { + backgroundColor: this.props.color.value + }; + + return ( +
    +
    +
    +
    {this.props.color.label}
    +
    {this.props.color.value}
    + +
    + {this.renderRemoving()} +
    + ); + } + +} + +Color.propTypes = { + color: React.PropTypes.object.isRequired, + onEdit: React.PropTypes.func.isRequired +}; diff --git a/lib/components/admin/panels/colors/edit.jsx b/lib/components/admin/panels/colors/edit.jsx new file mode 100644 index 000000000..06ea5b728 --- /dev/null +++ b/lib/components/admin/panels/colors/edit.jsx @@ -0,0 +1,65 @@ +import {Component} from 'relax-framework'; +import ColorPicker from 'react-colorpicker'; +import Input from '../../../input'; +import React from 'react'; +import Lightbox from '../../../lightbox'; + +import colorsActions from '../../../../client/actions/colors'; + +export default class EditColor extends Component { + getInitialState () { + return { + value: this.props.value || { + label: '', + value: '#ffffff' + } + }; + } + + closeEdit () { + this.props.onClose(); + } + + onEditColorChange (color) { + this.state.value.value = color.toHex(); + this.setState({ + value: this.state.value + }); + } + + onTitleChange (value) { + this.state.value.label = value; + this.setState({ + value: this.state.value + }); + } + + submit () { + if (this.state.value._id) { + colorsActions.update(this.state.value).then(() => this.closeEdit()); + } else { + colorsActions.add(this.state.value).then(() => this.closeEdit()); + } + } + + render () { + var isNew = this.props.value ? false : true; + var title = isNew ? 'Adding new color to palette' : 'Editing '+this.state.value.label; + var btn = isNew ? 'Add color to palette' : 'Change color'; + + return ( + + +
    + +
    + {btn} +
    + ); + } +} + +EditColor.propTypes = { + value: React.PropTypes.any, + onClose: React.PropTypes.func.isRequired +}; diff --git a/lib/components/admin/panels/colors/index.jsx b/lib/components/admin/panels/colors/index.jsx new file mode 100644 index 000000000..beb7ff8ed --- /dev/null +++ b/lib/components/admin/panels/colors/index.jsx @@ -0,0 +1,94 @@ +import {Component} from 'relax-framework'; +import Color from './color'; +import Edit from './edit'; +import React from 'react'; + +import colorsStore from '../../../../client/stores/colors'; + +export default class Colors extends Component { + getInitialState () { + return { + edit: false, + colors: this.context.colors + }; + } + + getInitialCollections () { + return { + colors: colorsStore.getCollection() + }; + } + + onAddNew (event) { + event.preventDefault(); + this.setState({ + edit: true, + editingColor: false + }); + } + + onEdit (color) { + this.setState({ + edit: true, + editingColor: color + }); + } + + closeEdit () { + this.setState({ + edit: false, + editingColor: false + }); + } + + renderColor (color) { + return ( + + ); + } + + renderColors () { + if(this.state.colors && this.state.colors.length > 0){ + return ( +
    + {this.state.colors.map(this.renderColor, this)} +
    + ); + } + else { + return ( +

    You don't have any color in your palette yet, you can add new colors on the right panel

    + ); + } + } + + renderEdit () { + if (this.state.edit) { + return ( + + ); + } + } + + render () { + return ( +
    + +
    + {this.renderColors()} +
    + {this.renderEdit()} +
    + ); + } +} + +Colors.contextTypes = { + colors: React.PropTypes.array.isRequired +}; diff --git a/lib/components/admin/panels/colors/new.jsx b/lib/components/admin/panels/colors/new.jsx new file mode 100644 index 000000000..325ef06ac --- /dev/null +++ b/lib/components/admin/panels/colors/new.jsx @@ -0,0 +1,96 @@ +import {Component} from 'relax-framework'; +import ColorPicker from 'react-colorpicker'; +import ColorActions from '../../../../client/actions/colors'; +import Input from '../../../input'; +import React from 'react'; + +export default class NewColor extends Component { + + getInitialState () { + return { + title: 'Add new color', + button: 'Add new color', + titleInput: '', + colorInput: '#000000' + }; + } + + onTitleChange (value) { + this.setState({ + titleInput: value + }); + } + + onColorChange (color) { + this.setState({ + colorInput: color.toHex() + }); + } + + addNew (event) { + event.preventDefault(); + + if(this.props.selected){ + ColorActions.update({ + _id: this.props.selected._id, + value: this.state.colorInput, + label: this.state.titleInput + }); + } + else{ + ColorActions + .add({ + label: this.state.titleInput, + value: this.state.colorInput + }) + .then(() => { + this.setState(this.getInitialState); + }); + } + } + + remove (event) { + event.preventDefault(); + + ColorActions.remove(this.props.selected._id); + } + + componentWillReceiveProps (nextProps) { + if(nextProps.selected) { + this.setState({ + title: 'Editing '+nextProps.selected.label+' color', + titleInput: nextProps.selected.label, + colorInput: nextProps.selected.value, + button: 'Change' + }); + } + else if(this.props.selected){ + this.setState(this.getInitialState()); + } + } + + renderRemoveButton () { + if(this.props.selected){ + return ( + Remove + ); + } + } + + render () { + return ( +
    + +
    + +
    + {this.state.button} + {this.renderRemoveButton()} +
    + ); + } +} + +NewColor.propTypes = { + selected: React.PropTypes.any +}; diff --git a/lib/components/admin/panels/fonts/custom-fonts.jsx b/lib/components/admin/panels/fonts/custom-fonts.jsx new file mode 100644 index 000000000..cbb925086 --- /dev/null +++ b/lib/components/admin/panels/fonts/custom-fonts.jsx @@ -0,0 +1,218 @@ +import {Component} from 'relax-framework'; +import React from 'react'; +import forEach from 'lodash.foreach'; +import Font from './font'; +import Utils from '../../../../utils'; +import Upload from '../../../upload'; + +export default class CustomFonts extends Component { + getInitialState () { + return { + customLoading: false, + customError: false, + titleInput: '', + files: [] + }; + } + + removeCustomFont (family, event) { + event.preventDefault(); + this.props.removeCustomFont(family); + } + + submitCustomFont (event) { + event.preventDefault(); + + // Validation of parameters + if(this.state.titleInput === ""){ + this.setState({ + customError: "Fill in your custom font family title" + }); + return; + } + + if(this.state.files.length === 0){ + this.setState({ + customError: "You haven't upload any font file" + }); + return; + } + + // Get each font file type + var types = []; + var filesInfo = []; + var files = this.state.files; + var re = /(?:\.([^.]+))?$/; + for(var i = 0; i < files.length; i++){ + const file = files[i]; + if(file.name && file.xhr && file.xhr.response){ + const type = re.exec(file.name)[1]; + + if(type !== undefined){ + types.push(type); + } + + // server response + filesInfo.push({ + name: file.name, + info: JSON.parse(file.xhr.response) + }); + } + } + + // At least woff is needed + var woff = types.indexOf("woff"); + if(woff === -1){ + this.setState({ + customError: "You need to upload the .woff font file type" + }); + return; + } + + // .eot needed for ie9 + var eot = types.indexOf("eot"); + if(eot === -1){ + this.setState({ + customError: "You need to upload the .eot font file as well to support IE9" + }); + return; + } + + // .ttf + var ttf = types.indexOf("ttf"); + if(ttf === -1){ + this.setState({ + customError: "Upload the ttf format to support Safari, Android and iOS" + }); + return; + } + + this.props.submitCustomFont( this.state.titleInput, filesInfo, types) + .then(() => { + forEach(this.state.files, (file) => { + file.previewElement.parentNode.removeChild(file.previewElement); + }); + + this.setState({ + titleInput: '', + files: [] + }); + }) + .catch((error) => { + this.setState({ + customError: "Error uploading fonts: "+error + }); + }); + } + + onTitleChange (event) { + this.setState({ + titleInput: event.target.value + }); + } + + customFontFileSuccess (file) { + this.state.files.push(file); + } + + customFontFileRemove (file) { + var files = this.state.files; + var index = -1; + for(var i = 0; i < files.length; i++){ + if(files[i].name === file.name){ + index = i; + break; + } + } + + if(index !== -1){ + this.state.files.splice(index, 1); + this.refs.uploadedFonts.querySelector(file.previewElement).remove(); + } + } + + renderList () { + if(this.props.customFonts && this.props.customFonts.length > 0){ + var customFonts = []; + + forEach(this.props.customFonts, (customFont) => { + let family = customFont.family; + customFonts.push( +
    + +
    +

    {Utils.filterFontFamily(family)}

    +

    Custom font

    +
    + +
    + ); + }); + + return customFonts; + } + } + + renderCover () { + if(this.state.customLoading){ + return ( +
    +

    Loading your fonts

    +
    + ); + } + } + + renderError () { + if(this.state.customError !== false){ + return ( + {this.state.customError} + ); + } + } + + render () { + return ( +
    +
    + {this.renderList()} +
    + +
    + Add new custom font +
    +
    +
    +
    Font title
    + +
    +
    + +
    + +
    + Submit custom font + {this.renderError()} +
    +
    + {this.renderCover()} +
    + ); + } +} + +CustomFonts.propTypes = { + removeCustomFont: React.PropTypes.func.isRequired, + submitCustomFont: React.PropTypes.func.isRequired, + customFonts: React.PropTypes.array.isRequired, + previewText: React.PropTypes.string.isRequired +}; diff --git a/lib/components/admin/panels/fonts/font.jsx b/lib/components/admin/panels/fonts/font.jsx new file mode 100644 index 000000000..5bb2beafe --- /dev/null +++ b/lib/components/admin/panels/fonts/font.jsx @@ -0,0 +1,24 @@ +import {Component} from 'relax-framework'; +import React from 'react'; +import Utils from '../../../../utils'; + +export default class Font extends Component { + + render () { + + var style = this.props.style || {}; + style.fontFamily = this.props.family; + Utils.processFVD(style, this.props.fvd); + + var content = ''; + + if(this.props.input) { + content = ; + } + else { + content =
    {this.props.text}
    ; + } + + return content; + } +} diff --git a/lib/components/admin/panels/fonts/fonts-list.jsx b/lib/components/admin/panels/fonts/fonts-list.jsx new file mode 100644 index 000000000..7693400ad --- /dev/null +++ b/lib/components/admin/panels/fonts/fonts-list.jsx @@ -0,0 +1,78 @@ +import {Component} from 'relax-framework'; +import React from 'react'; +import forEach from 'lodash.foreach'; +import Font from './font'; +import Utils from '../../../../utils'; + +export default class Fonts extends Component { + changePreviewText (event) { + this.props.onPreviewTextChange(event.target.value); + } + changePreviewLayout (to, event) { + event.preventDefault(); + this.props.onPreviewLayoutChange(to); + } + + renderList () { + var list = []; + forEach(this.props.data.fonts, (variants, family) => { + variants.map((variant, ind) => { + var key = (family+variant).replace(/ /g, '_'); + var font = ( +
    + +
    +

    {Utils.filterFontFamily(family)}

    +

    {Utils.filterFVD(variant)}

    +
    +
    + ); + + list.push(font); + }, this); + }); + + if(list.length === 0){ + return ( +
    +
    + error_outline +
    +
    +

    No fonts added yet!

    +

    Click on 'add fonts' button above to add new

    +
    +
    + ); + } + + return list; + } + + renderCover () { + if(this.props.loading){ + return ( +
    +

    Loading your fonts

    +
    + ); + } + } + + render () { + return ( +
    +
    + {this.renderList()} + {this.renderCover()} +
    +
    + ); + } +} + +Fonts.propTypes = { + data: React.PropTypes.object.isRequired, + onPreviewTextChange: React.PropTypes.func.isRequired, + loading: React.PropTypes.bool.isRequired +}; diff --git a/lib/components/admin/panels/fonts/index.jsx b/lib/components/admin/panels/fonts/index.jsx new file mode 100644 index 000000000..553461fa1 --- /dev/null +++ b/lib/components/admin/panels/fonts/index.jsx @@ -0,0 +1,487 @@ +import {Component} from 'relax-framework'; +import CustomFonts from './custom-fonts'; +import FontsList from './fonts-list'; +import merge from 'lodash.merge'; +import React from 'react'; +import InputValidation from '../../../input-validation'; +import Lightbox from '../../../lightbox'; +import forEach from 'lodash.foreach'; +import Q from 'q'; +import cx from 'classnames'; + +import settingsActions from '../../../../client/actions/settings'; +import fontsActions from '../../../../client/actions/fonts'; + +export default class Fonts extends Component { + getInitialState () { + var settings = this.parseSettings(this.context.settings); + + return { + data: merge(Fonts.defaults, settings.fonts || {}), + tab: 0, + loading: false, + manager: false + }; + } + + changeTab (tab, event) { + event.preventDefault(); + + this.setState({ + tab: tab + }); + } + + save () { + settingsActions + .saveSettings({fonts: this.state.data}); + } + + loadingFontsFinished () { + this.state.data.fonts = merge({}, this.newFonts); + this.newFonts = null; + delete this.newFonts; + + this.save(); + + this.setState({ + loading: false, + data: this.state.data + }); + } + + fontActive (familyName, fvd) { + if(!this.newFonts[familyName]){ + this.newFonts[familyName] = []; + } + + this.newFonts[familyName].push(fvd); + } + + loadFonts () { + var events = { + active: this.loadingFontsFinished.bind(this), + fontactive: this.fontActive.bind(this) + }; + + this.newFonts = {}; + var params = merge({}, events, this.state.data.webfontloader); + + WebFont.load(params); + + this.setState({ + loading: true + }); + } + + changedInput (value) { + var inputData = this.state.data.input; + var previousValid; + + this.state.data.webfontloader = this.state.data.webfontloader || {}; + var webfontloader = this.state.data.webfontloader; + + // Google fonts validation + if(this.state.tab === 0){ + previousValid = inputData.google.valid; + inputData.google.input = value; + inputData.google.valid = false; + + var paramsStr = value.split("?"); + + // Not valid + if(paramsStr.length !== 2){ + return; + } + + var params = {}, re = /[?&]?([^=]+)=([^&]*)/g; + var tokens = re.exec(paramsStr[1]); + + while(tokens) { + params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]); + tokens = re.exec(paramsStr[1]); + } + + // Exists + if(params.family){ + inputData.google.valid = true; + + if(!webfontloader.google){ + webfontloader.google = { + families: [] + }; + } + else{ + webfontloader.google.families = []; + } + + // Object {family: "Lobster|Open+Sans:400,700", subset: "latin,cyrillic-ext,cyrillic"} + var families = params.family.split("|"); + for(var i = 0; i < families.length; i++){ + var googleFont = families[i]; + + // Might not have multiple weights + if(families[i].indexOf(':') === -1){ + googleFont += ":"; + } + + if(params.subset){ + googleFont += ":"+params.subset; + } + else{ + googleFont += ":latin"; + } + + webfontloader.google.families.push(googleFont); + } + + this.loadFonts(); + } + + if(!inputData.google.valid && webfontloader.google){ + delete webfontloader.google; + } + + if(previousValid && !inputData.google.valid){ + this.loadFonts(); + } + } + + // Typekit validation + else if(this.state.tab === 1){ + previousValid = inputData.typekit.valid; + inputData.typekit.input = value; + inputData.typekit.valid = false; + + if(value.length === 7){ + inputData.typekit.valid = true; + + webfontloader.typekit = webfontloader.typekit || {}; + + webfontloader.typekit.id = value; + this.loadFonts(); + } + + if(!inputData.typekit.valid && webfontloader.typekit){ + delete webfontloader.typekit; + } + + if(previousValid && !inputData.typekit.valid){ + this.loadFonts(); + } + } + + // Fonts.com (monotype) validation + else if(this.state.tab === 2){ + previousValid = inputData.monotype.valid; + inputData.monotype.input = value; + inputData.monotype.valid = false; + + if(value.length === 36){ + var regex = new RegExp( /[0-9|a-z]{8}-[0-9|a-z]{4}-[0-9|a-z]{4}-[0-9|a-z]{4}-[0-9|a-z]{12}/g ); + inputData.monotype.valid = regex.test(value); + } + + // valid + if(inputData.monotype.valid){ + webfontloader.monotype = webfontloader.monotype || {}; + + webfontloader.monotype.projectId = value; + this.loadFonts(); + } + else if(webfontloader.monotype){ + delete webfontloader.monotype; + } + + if(previousValid && !inputData.monotype.valid){ + this.loadFonts(); + } + } + + // Font Deck validation + else if(this.state.tab === 3){ + previousValid = inputData.fontdeck.valid; + inputData.fontdeck.input = value; + inputData.fontdeck.valid = false; + + if(value.length === 5){ + inputData.fontdeck.valid = true; + webfontloader.fontdeck = webfontloader.fontdeck || {}; + + webfontloader.fontdeck.id = value; + this.loadFonts(); + } + + if(!inputData.fontdeck.valid && webfontloader.fontdeck){ + delete webfontloader.fontdeck; + } + + if(previousValid && !inputData.fontdeck.valid){ + this.loadFonts(); + } + } + } + + onPreviewTextChange (event) { + this.state.data.previewText = event.target.value; + this.setState({ + data: this.state.data + }); + } + + onPreviewLayoutChange (layout, event) { + event.preventDefault(); + this.state.data.previewLayout = layout; + this.setState({ + data: this.state.data + }); + } + + + removeCustomFont (family) { + forEach(this.state.data.customFonts, (obj, index) => { + if(obj.family === family){ + + fontsActions.remove(obj.id); + + this.state.data.customFonts.splice(index, 1); + + var ind = this.state.data.webfontloader.custom.families.indexOf(family); + if(ind !== -1){ + this.state.data.webfontloader.custom.families.splice(ind, 1); + } + + this.loadFonts(); + + return false; + } + }); + } + + onCustomSubmit (title, files, types) { + return Q() + .then(() => fontsActions.submit(files)) + .then((id) => { + // All good -> process + var webfontloader = this.state.data.webfontloader; + this.state.customError = false; + + // map types to file + var map = {}; + for(var a = 0; a < files.length; a++){ + map[types[a]] = files[a].name; + } + + var rule = "font-family: '"+title+"';"; + rule += "src: url('/fonts/"+id+"/"+map.eot+"'); "; + rule += "src: "; + + // try woff2 + var woff2 = types.indexOf("woff2"); + if(woff2 !== -1){ + rule += "url('/fonts/"+id+"/"+map.woff2+"'), "; + } + + rule += "url('/fonts/"+id+"/"+map.woff+"'), "; + rule += "url('/fonts/"+id+"/"+map.ttf+"'); "; + + var s = document.createElement('style'); + s.type = "text/css"; + document.getElementsByTagName('head')[0].appendChild(s); + + var css = "@font-face {" + rule + "}"; + if (s.styleSheet){ + s.styleSheet.cssText = css; + } else { + s.appendChild(document.createTextNode(css)); + } + + webfontloader.custom = webfontloader.custom || { families: [] }; + webfontloader.custom.families.push(title); + + this.state.data.customFonts = this.state.data.customFonts || []; + this.state.data.customFonts.push({ + family: title, + files: map, + id: id + }); + + this.loadFonts(); + + return true; + }) + .catch((error) => { + console.log(error); + }); + } + + openManager (event) { + event.preventDefault(); + this.setState({ + manager: true + }); + } + + closeManager () { + this.setState({ + manager: false + }); + } + + renderTabButton (tabButton, a) { + var is_valid = this.state.data.input[tabButton.lib].valid; + + if(tabButton.lib === 'custom'){ + is_valid = this.state.data.customFonts && this.state.data.customFonts.length > 0; + } + + var classes = 'fp-tab '+(this.state.tab === a ? 'active ' : '')+(is_valid ? 'validated ' : ''); + return ( + + + {tabButton.title} + + ); + } + + renderTabContent () { + var currentTab = Fonts.tabs[this.state.tab]; + + // Font library + if(this.state.tab !== Fonts.tabs.length - 1){ + const lib = currentTab.lib; + const input = this.state.data.input[lib]; + + return ( +
    +

    {currentTab.label}

    + +
    + ); + } + // Custom fonts + else{ + return ( + + ); + } + } + + renderManager () { + if (this.state.manager) { + return ( + +
    +
    + {Fonts.tabs.map(this.renderTabButton.bind(this))} +
    +
    + {this.renderTabContent()} +
    +
    +
    + ); + } + } + + render () { + + return ( +
    + +
    + +
    + {this.renderManager()} +
    + ); + } +} + +Fonts.contextTypes = { + settings: React.PropTypes.array.isRequired +}; + +Fonts.tabs = [ +{ + icon: 'fp-tab-ic fp-google', + title: 'Google Fonts', + lib: 'google', + label: 'Google fonts fonts link' +}, +{ + icon: 'fp-tab-ic fp-typekit', + title: 'Typekit', + lib: 'typekit', + label: 'Typekit kit id' +}, +{ + icon: 'fp-tab-ic fp-fontscom', + title: 'Fonts.com', + lib: 'monotype', + label: 'Fonts.com project id' +}, +{ + icon: 'fp-tab-ic fp-fontdeck', + title: 'Font Deck', + lib: 'fontdeck', + label: 'Fontdeck project id' +}, +{ + icon: 'fp-tab-icon fa fa-font', + title: 'Custom Fonts', + lib: 'custom' +} +]; + +Fonts.defaults = { + previewText: 'Abc', + previewLayout: 'grid', // grid || list + input: { + google: { + input: '', + valid: false + }, + typekit: { + input: '', + valid: false + }, + fontdeck: { + input: '', + valid: false + }, + monotype: { + input: '', + valid: false + }, + custom: { + input: '', + valid: false + } + }, + customFonts: [], + fonts: {}, + webfontloader: {} +}; diff --git a/lib/components/admin/panels/index.js b/lib/components/admin/panels/index.js new file mode 100644 index 000000000..55a1d624b --- /dev/null +++ b/lib/components/admin/panels/index.js @@ -0,0 +1,27 @@ +import Settings from './settings'; +import Pages from './pages'; +import Page from './page'; +import Fonts from './fonts'; +import Media from './media'; +import Colors from './colors'; +import Schemas from './schemas'; +import SchemasNew from './schemas-new'; +import Schema from './schema'; +import SchemaEntry from './schema-entry'; +import Users from './users'; +import UserEdit from './user-edit'; + +export default { + settings: Settings, + pages: Pages, + page: Page, + fonts: Fonts, + media: Media, + colors: Colors, + schemas: Schemas, + schemasNew: SchemasNew, + schema: Schema, + schemaEntry: SchemaEntry, + users: Users, + userEdit: UserEdit +}; diff --git a/lib/components/admin/panels/media/grid/index.jsx b/lib/components/admin/panels/media/grid/index.jsx new file mode 100644 index 000000000..d27b980b8 --- /dev/null +++ b/lib/components/admin/panels/media/grid/index.jsx @@ -0,0 +1,26 @@ +import {Component} from 'relax-framework'; +import React from 'react'; +import Item from './item'; + +export default class MediaGrid extends Component { + renderItem (data) { + var selected = this.props.selected.indexOf(data._id) !== -1; + return ( + + ); + } + + render () { + return ( +
    + {this.props.media.map(this.renderItem, this)} +
    + ); + } +} + +MediaGrid.propTypes = { + media: React.PropTypes.array.isRequired, + selected: React.PropTypes.array.isRequired, + onSelect: React.PropTypes.func.isRequired +}; diff --git a/lib/components/admin/panels/media/grid/item.jsx b/lib/components/admin/panels/media/grid/item.jsx new file mode 100644 index 000000000..546cc5b14 --- /dev/null +++ b/lib/components/admin/panels/media/grid/item.jsx @@ -0,0 +1,57 @@ +import {Component} from 'relax-framework'; +import React from 'react'; +import Utils from '../../../../../utils'; + +import mediaActions from '../../../../../client/actions/media'; + +export default class MediaGridItem extends Component { + getInitialState () { + return { + requested: false + }; + } + + onSelect (id, event) { + event.preventDefault(); + this.props.onSelect(id); + } + + render () { + var className = ''; + if (this.props.selected){ + className += 'active'; + } + + const width = 350; + const height = 190; + + const variation = Utils.getBestImageVariation(this.props.data.variations, width, height); + + var style = {}; + + if (variation !== false) { + style.backgroundImage = 'url('+variation.url+')'; + } else { + style.backgroundColor = '#cccccc'; + + if (!this.state.requested) { + this.state.requested = true; + mediaActions.resize({ + id: this.props.data._id, + width, + height + }); + } + } + + return ( + + ); + } +} + +MediaGridItem.propTypes = { + data: React.PropTypes.object.isRequired, + selected: React.PropTypes.bool.isRequired, + onSelect: React.PropTypes.func.isRequired +}; diff --git a/lib/components/admin/panels/media/index.jsx b/lib/components/admin/panels/media/index.jsx new file mode 100644 index 000000000..96397d429 --- /dev/null +++ b/lib/components/admin/panels/media/index.jsx @@ -0,0 +1,183 @@ +import {Component} from 'relax-framework'; +import List from './list'; +import Grid from './grid'; +import React from 'react'; +import Upload from '../../../upload'; +import Filter from '../../../filter'; +import AlertBox from '../../../alert-box'; +import Lightbox from '../../../lightbox'; +import cx from 'classnames'; + +import mediaStore from '../../../../client/stores/media'; +import mediaActions from '../../../../client/actions/media'; + +export default class MediaManager extends Component { + getInitialState () { + return { + display: 'list', + media: this.context.media, + upload: false, + selected: [], + removing: false + }; + } + + getInitialCollections () { + return { + media: mediaStore.getCollection() + }; + } + + onSuccess (file, mediaItem, progressFinal) { + mediaActions.add(mediaItem); + } + + listClick (event) { + event.preventDefault(); + this.setState({ + display: 'list' + }); + } + + gridClick (event) { + event.preventDefault(); + this.setState({ + display: 'grid' + }); + } + + onSelect (id) { + var index = this.state.selected.indexOf(id); + + if(index === -1){ + this.state.selected.push(id); + } else { + this.state.selected.splice(index, 1); + } + this.setState({ + selected: this.state.selected + }); + } + + removeSelected (event) { + event.preventDefault(); + this.setState({ + removing: true + }); + } + + cancelRemove (event) { + event.preventDefault(); + this.setState({ + removing: false + }); + } + + confirmRemove (event) { + event.preventDefault(); + mediaActions.removeBulk(this.state.selected); + this.setState({ + removing: false, + selected: [] + }); + } + + openUpload (event) { + event.preventDefault(); + this.setState({ + upload: true + }); + } + + closeUpload () { + this.setState({ + upload: false + }); + } + + renderItems () { + if(this.state.display === 'list'){ + return ( + + ); + } else if (this.state.display === 'grid') { + return ( + + ); + } + } + + renderSelectedMenu () { + if(this.state.selected.length > 0) { + let str = this.state.selected.length+' items selected '; + return ( + + {str} + Remove them + + ); + } + } + + renderLightbox () { + if (this.state.upload) { + return ( + + + + ); + } + } + + renderRemoving () { + if (this.state.removing) { + const label = 'Are you sure you want to remove the selected media elements?'; + return ( + +
    {label}
    + +
    + ); + } + } + + render () { + return ( +
    + +
    + {this.renderSelectedMenu()} + {this.renderItems()} +
    + {this.renderLightbox()} + {this.renderRemoving()} +
    + ); + } +} + +MediaManager.contextTypes = { + media: React.PropTypes.array.isRequired +}; diff --git a/lib/components/admin/panels/media/list.jsx b/lib/components/admin/panels/media/list.jsx new file mode 100644 index 000000000..088d10a15 --- /dev/null +++ b/lib/components/admin/panels/media/list.jsx @@ -0,0 +1,47 @@ +import {Component} from 'relax-framework'; +import React from 'react'; +import moment from 'moment'; + +export default class MediaList extends Component { + + onSelect (id) { + this.props.onSelect(id); + } + + renderItem (data) { + var date = moment(data.date).format("Do MMMM YYYY"); + var className = 'entry'; + + if(this.props.selected.indexOf(data._id) !== -1){ + className += ' active'; + } + + return ( +
    +
    + +
    +
    +
    {data.name}
    +
    {data.dimension.width+'x'+data.dimension.height}
    +
    {data.size}
    +
    {date}
    +
    +
    + ); + } + + render () { + return ( +
    + {this.props.media.map(this.renderItem, this)} +
    + ); + } +} + +MediaList.propTypes = { + media: React.PropTypes.array.isRequired, + selected: React.PropTypes.array.isRequired, + onSelect: React.PropTypes.func.isRequired +}; diff --git a/lib/components/admin/panels/page.jsx b/lib/components/admin/panels/page.jsx new file mode 100644 index 000000000..d2c8de32f --- /dev/null +++ b/lib/components/admin/panels/page.jsx @@ -0,0 +1,15 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import PageBuilder from '../../page-builder'; + +export default class Page extends Component { + render () { + return ( + + ); + } +} + +Page.contextTypes = { + page: React.PropTypes.object.isRequired +}; diff --git a/lib/components/admin/panels/pages/entry.jsx b/lib/components/admin/panels/pages/entry.jsx new file mode 100644 index 000000000..81c56bfd3 --- /dev/null +++ b/lib/components/admin/panels/pages/entry.jsx @@ -0,0 +1,136 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import moment from 'moment'; +import cx from 'classnames'; +import A from '../../../a'; +import cloneDeep from 'lodash.clonedeep'; +import Q from 'q'; +import Lightbox from '../../../lightbox'; + +import pageActions from '../../../../client/actions/page'; + +export default class Entry extends Component { + getInitialState () { + return { + removing: false + }; + } + + removePage (event) { + event.preventDefault(); + this.setState({ + removing: true + }); + } + + cancelRemove (event) { + event.preventDefault(); + this.setState({ + removing: false + }); + } + + confirmRemove (event) { + event.preventDefault(); + pageActions.remove(this.props.page._id); + this.setState({ + removing: false + }); + } + + resolveSlug (slug, it) { + var resultSlug = slug + (it > 0 ? '-'+it : ''); + + return Q() + .then(() => pageActions.validateSlug(resultSlug)) + .then((response) => { + var slugValid = !response; + + if (slugValid) { + return resultSlug; + } else { + return this.resolveSlug(slug, it+1); + } + }); + } + + duplicatePage (event) { + event.preventDefault(); + var clonePage = cloneDeep(this.props.page); + delete clonePage._id; + delete clonePage.date; + delete clonePage.actions; + clonePage.title += ' (copy)'; + clonePage.slug += '-copy'; + clonePage.state = 'draft'; + + this.resolveSlug(clonePage.slug, 0).then((slug) => { + clonePage.slug = slug; + pageActions.add(clonePage); + }); + } + + renderRemoving () { + if (this.state.removing) { + const label = 'Are you sure you want to remove '+this.props.page.title+' page?'; + const label1 = 'You\'ll loose this page\'s data forever!'; + return ( + +
    {label}
    +
    {label1}
    + +
    + ); + } + } + + render () { + const page = this.props.page; + + let editLink = '/admin/page/'+page.slug; + let viewLink = '/'+page.slug; + const published = page.state === 'published'; + let date = 'Created - ' + moment(page.date).format('MMMM Do YYYY'); + + return ( +
    +
    + {published ? 'cloud_queue' : 'cloud_off'} +
    + + {this.renderRemoving()} +
    + ); + } +} + +Entry.propTypes = { + page: React.PropTypes.object.isRequired +}; diff --git a/lib/components/admin/panels/pages/index.jsx b/lib/components/admin/panels/pages/index.jsx new file mode 100644 index 000000000..542542837 --- /dev/null +++ b/lib/components/admin/panels/pages/index.jsx @@ -0,0 +1,89 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import List from './list'; +import Filter from '../../../filter'; +import Lightbox from '../../../lightbox'; +import Manage from './manage'; + +import pagesStore from '../../../../client/stores/pages'; +import pageActions from '../../../../client/actions/page'; + +export default class Pages extends Component { + getInitialState () { + return { + pages: this.context.pages, + search: (this.context.query && this.context.query.s) || '', + lightbox: false + }; + } + + getInitialCollections () { + return { + pages: pagesStore.getCollection() + }; + } + + onAddNew (values) { + pageActions + .add({ + title: values.title, + slug: values.slug + }) + .then(() => { + this.setState({ + lightbox: false + }); + }); + } + + addNewClick (event) { + event.preventDefault(); + this.setState({ + lightbox: true + }); + } + + closeLightbox () { + this.setState({ + lightbox: false + }); + } + + renderLightbox () { + if (this.state.lightbox) { + return ( + + + + ); + } + } + + render () { + return ( +
    + +
    + +
    + {this.renderLightbox()} +
    + ); + } +} + +Pages.contextTypes = { + pages: React.PropTypes.array.isRequired, + query: React.PropTypes.object +}; diff --git a/lib/components/admin/panels/pages/list.jsx b/lib/components/admin/panels/pages/list.jsx new file mode 100644 index 000000000..a7983b637 --- /dev/null +++ b/lib/components/admin/panels/pages/list.jsx @@ -0,0 +1,23 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import Entry from './entry'; + +export default class List extends Component { + renderEntry (page) { + return ( + + ); + } + + render () { + return ( +
    + {this.props.data.map(this.renderEntry, this)} +
    + ); + } +} + +List.propTypes = { + data: React.PropTypes.array.isRequired +}; diff --git a/lib/components/admin/panels/pages/manage.jsx b/lib/components/admin/panels/pages/manage.jsx new file mode 100644 index 000000000..db2d3f75e --- /dev/null +++ b/lib/components/admin/panels/pages/manage.jsx @@ -0,0 +1,42 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import TitleSlug from '../../../title-slug'; + +import pageActions from '../../../../client/actions/page'; + +export default class Manage extends Component { + getInitialState () { + return { + title: '', + slug: '' + }; + } + + onChange (values) { + this.setState(values); + } + + onSubmit (event) { + event.preventDefault(); + this.props.onSubmit(this.state); + } + + render () { + return ( +
    + + + Create page + + ); + } +} + +Manage.propTypes = { + onSubmit: React.PropTypes.func.isRequired +}; diff --git a/lib/components/admin/panels/schema-entry/index.jsx b/lib/components/admin/panels/schema-entry/index.jsx new file mode 100644 index 000000000..5108427c6 --- /dev/null +++ b/lib/components/admin/panels/schema-entry/index.jsx @@ -0,0 +1,71 @@ +import {Component} from 'relax-framework'; +import merge from 'lodash.merge'; +import OptionsList from '../../../options-list'; +import React from 'react'; +import Breadcrumbs from '../../../breadcrumbs'; +import TitleSlug from '../../../title-slug'; + +import schemaEntriesActionsFactory from '../../../../client/actions/schema-entries'; + +export default class SchemaEntry extends Component { + getInitialState () { + this.schemaEntriesActions = schemaEntriesActionsFactory(this.context.schema.slug); + return { + opened: false, + schema: this.context.schema, + schemaEntry: this.context.schemaEntry + }; + } + + onSubmit (event) { + event.preventDefault(); + + this.schemaEntriesActions + .update(this.state.schemaEntry) + .then(() => { + + }); + } + + onFieldChange (id, value) { + this.state.schemaEntry[id] = value; + this.setState({ + schemaEntry: this.state.schemaEntry + }); + } + + onChange (values) { + merge(this.state.schemaEntry, values); + this.setState({ + schemaEntry: this.state.schemaEntry + }); + } + + render () { + return ( +
    +
    + +
    +
    +
    + + + + +
    +
    + ); + } +} + +SchemaEntry.contextTypes = { + schema: React.PropTypes.object.isRequired, + schemaEntry: React.PropTypes.object.isRequired, + breadcrumbs: React.PropTypes.array.isRequired +}; diff --git a/lib/components/admin/panels/schema/entry.jsx b/lib/components/admin/panels/schema/entry.jsx new file mode 100644 index 000000000..bd845415a --- /dev/null +++ b/lib/components/admin/panels/schema/entry.jsx @@ -0,0 +1,107 @@ +import A from '../../../a'; +import Lightbox from '../../../lightbox'; +import React from 'react'; +import {Component} from 'relax-framework'; +import moment from 'moment'; +import cx from 'classnames'; + +import schemaEntriesActionsFactory from '../../../../client/actions/schema-entries'; + +export default class Entry extends Component { + getInitialState () { + return { + removing: false + }; + } + + onRemove (event) { + event.preventDefault(); + this.setState({ + removing: true + }); + } + + cancelRemove (event) { + event.preventDefault(); + this.setState({ + removing: false + }); + } + + confirmRemove (event) { + event.preventDefault(); + schemaEntriesActionsFactory(this.props.schema.slug).remove(this.props.schemaItem._id); + this.setState({ + removing: false + }); + } + + renderRemoving () { + if (this.state.removing) { + const label = 'Are you sure you want to remove the post '+this.props.schemaItem.title+'?'; + const label1 = 'This action cannot be reverted'; + return ( + +
    {label}
    +
    {label1}
    + +
    + ); + } + } + + render () { + const schemaItem = this.props.schemaItem; + let editLink = '/admin/schemas/'+this.props.schema.slug+'/'+schemaItem.slug; + let buildLink = '/admin/schema/'+this.props.schema.slug+'/'+schemaItem.slug; + let viewLink = '/'+this.props.schema.slug+'/'+schemaItem.slug; + const published = schemaItem.state === 'published'; + let date = 'Created - ' + moment(schemaItem.date).format('MMMM Do YYYY'); + + return ( +
    +
    + {published ? 'cloud_queue' : 'cloud_off'} +
    + + {this.renderRemoving()} +
    + ); + } +} + +Entry.propTypes = { + schema: React.PropTypes.object.isRequired, + schemaItem: React.PropTypes.object.isRequired +}; diff --git a/lib/components/admin/panels/schema/index.jsx b/lib/components/admin/panels/schema/index.jsx new file mode 100644 index 000000000..ea44e4b93 --- /dev/null +++ b/lib/components/admin/panels/schema/index.jsx @@ -0,0 +1,79 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import List from './list'; +import Lightbox from '../../../lightbox'; +import Filter from '../../../filter'; +import Manage from './manage'; +import Breadcrumbs from '../../../breadcrumbs'; + +import schemaEntriesStoreFactory from '../../../../client/stores/schema-entries'; + +export default class Schema extends Component { + getInitialState () { + return { + opened: false, + schema: this.context.schema, + schemaEntries: this.context.schemaEntries + }; + } + + getInitialCollections () { + return { + schemaEntries: schemaEntriesStoreFactory(this.context.schema.slug).getCollection() + }; + } + + addNewClick (event) { + event.preventDefault(); + + this.setState({ + opened: true + }); + } + + onClose () { + this.setState({ + opened: false + }); + } + + renderLightbox () { + if(this.state.opened){ + var title = 'Add new entry to ' + this.state.schema.title; + return ( + + + + ); + } + } + + render () { + return ( +
    + +
    + +
    + {this.renderLightbox()} +
    + ); + } +} + +Schema.contextTypes = { + schemaEntries: React.PropTypes.array.isRequired, + schema: React.PropTypes.object.isRequired, + breadcrumbs: React.PropTypes.array.isRequired +}; diff --git a/lib/components/admin/panels/schema/list.jsx b/lib/components/admin/panels/schema/list.jsx new file mode 100644 index 000000000..9869616be --- /dev/null +++ b/lib/components/admin/panels/schema/list.jsx @@ -0,0 +1,24 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import Entry from './entry'; + +export default class List extends Component { + renderEntry (schemaItem) { + return ( + + ); + } + + render () { + return ( +
    + {this.props.schemaEntries.map(this.renderEntry, this)} +
    + ); + } +} + +List.propTypes = { + schemaEntries: React.PropTypes.array, + schema: React.PropTypes.object +}; diff --git a/lib/components/admin/panels/schema/manage.jsx b/lib/components/admin/panels/schema/manage.jsx new file mode 100644 index 000000000..2102c0ebe --- /dev/null +++ b/lib/components/admin/panels/schema/manage.jsx @@ -0,0 +1,67 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import merge from 'lodash.merge'; +import OptionsList from '../../../options-list'; +import TitleSlug from '../../../title-slug'; + +import schemaEntriesActionsFactory from '../../../../client/actions/schema-entries'; + +export default class Manage extends Component { + getInitialState () { + return { + title: '', + slug: '', + values: {} + }; + } + + onSubmit (event) { + event.preventDefault(); + + schemaEntriesActionsFactory(this.props.schema.slug) + .add(merge( + { + title: this.state.title, + slug: this.state.slug + }, + this.state.values + )) + .then(() => { + this.setState({ + title: '', + slug: '', + values: {} + }); + }); + } + + onChange (values) { + this.setState(values); + } + + onFieldChange (id, value) { + this.state.values[id] = value; + this.setState({ + values: this.state.values + }); + } + + render () { + return ( +
    + + + + + ); + } +} + +Manage.propTypes = { + schema: React.PropTypes.object.isRequired +}; diff --git a/lib/components/admin/panels/schemas-new/builder.jsx b/lib/components/admin/panels/schemas-new/builder.jsx new file mode 100644 index 000000000..466bb8546 --- /dev/null +++ b/lib/components/admin/panels/schemas-new/builder.jsx @@ -0,0 +1,166 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import Combobox from '../../../combobox'; +import Checkbox from '../../../checkbox'; +import Input from '../../../input'; +import merge from 'lodash.merge'; +import {Types} from '../../../../types'; +import Prop from './prop'; +import forEach from 'lodash.foreach'; +import clone from 'lodash.clone'; + +var defaults = { + id: 'New prop', + type: 'String', + required: false +}; + +export default class SchemasBuilder extends Component { + getInitialState () { + return { + fields: [], + values: merge({}, defaults), + selected: false + }; + } + + onAddSchemaField (event) { + event.preventDefault(); + + const copy = clone(defaults); + this.state.fields.push(copy); + + this.setState({ + fields: this.state.fields, + selected: this.state.fields.length - 1 + }); + + this.props.onChange(this.state.fields); + } + + onChange (id, value) { + this.state.values[id] = value; + this.setState({ + values: this.state.values + }); + } + + onRemoveProp (id) { + forEach(this.state.fields, (field, key) => { + if (field.id === id) { + this.state.fields.splice(key, 1); + return false; + } + }); + this.setState({ + fields: this.state.fields + }); + this.props.onChange(this.state.fields); + } + + renderFieldEntry (field, index) { + let selected = this.state.selected === index; + return ( + + ); + } + + renderFields () { + return ( +
    + {this.renderFieldEntry({ + id: 'Title', + type: 'String', + required: true, + locked: true + })} + {this.renderFieldEntry({ + id: 'Slug', + type: 'String', + required: true, + locked: true + })} + {this.renderFieldEntry({ + id: 'Date', + type: 'Date', + required: true, + locked: true + })} + {this.state.fields.map(this.renderFieldEntry, this)} +
    + ); + } + + renderOptions () { + if (this.state.selected !== false) { + let types = Object.keys(Types).sort(); + let values = this.state.fields[this.state.selected]; + return ( +
    +
    +
    Option id
    + +
    +
    +
    Type
    + +
    +
    +
    Is required
    + +
    +
    + ); + } else { + return ( +
    +
    +
    + error_outline +
    +
    +

    Select a property on the left to edit

    +

    Or click the add new to add a new property

    +
    +
    +
    + ); + } + } + + render () { + return ( +
    +
    Schema properties
    +
    +
    +
    Properties
    + {this.renderFields()} +
    + add_circle_outline + Add new property +
    +
    +
    +
    Selected property options
    +
    + {this.renderOptions()} +
    +
    +
    +
    + ); + } +} + +SchemasBuilder.propTypes = { + onChange: React.PropTypes.func.isRequired +}; diff --git a/lib/components/admin/panels/schemas-new/index.jsx b/lib/components/admin/panels/schemas-new/index.jsx new file mode 100644 index 000000000..01dbcf9b3 --- /dev/null +++ b/lib/components/admin/panels/schemas-new/index.jsx @@ -0,0 +1,66 @@ +import Builder from './builder'; +import {Component} from 'relax-framework'; +import React from 'react'; +import TitleSlug from '../../../title-slug'; +import Breadcrumbs from '../../../breadcrumbs'; + +import schemaActions from '../../../../client/actions/schema'; + +export default class SchemasNew extends Component { + getInitialState () { + return { + schema: [], + title: '', + slug: '' + }; + } + + onAddNew (event) { + event.preventDefault(); + + schemaActions + .add({ + title: this.state.title, + slug: this.state.slug, + fields: this.state.schema + }) + .then(() => { + this.setState({ + title: '', + slug: '', + hasTypedSlug: false + }); + }); + } + + onSchemaChange (schema) { + this.setState({ + schema + }); + } + + onChange (values) { + this.setState(values); + } + + render () { + return ( +
    +
    + +
    +
    +
    + + +
    Save schema
    + +
    +
    + ); + } +} + +SchemasNew.contextTypes = { + breadcrumbs: React.PropTypes.array.isRequired +}; diff --git a/lib/components/admin/panels/schemas-new/prop.jsx b/lib/components/admin/panels/schemas-new/prop.jsx new file mode 100644 index 000000000..01ef3b55f --- /dev/null +++ b/lib/components/admin/panels/schemas-new/prop.jsx @@ -0,0 +1,38 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import cx from 'classnames'; + +export default class Prop extends Component { + onRemove (event) { + event.preventDefault(); + this.props.onRemove(this.props.prop.id); + } + + renderRemove () { + if (!this.props.prop.locked) { + return ( +
    + delete +
    + ); + } + } + + render () { + return ( +
    +
    +
    {this.props.prop.id}
    +
    {this.props.prop.type}
    +
    + {this.renderRemove()} +
    + ); + } +} + +Prop.propTypes = { + prop: React.PropTypes.object.isRequired, + onRemove: React.PropTypes.func.isRequired, + selected: React.PropTypes.bool.isRequired +}; diff --git a/lib/components/admin/panels/schemas/entry.jsx b/lib/components/admin/panels/schemas/entry.jsx new file mode 100644 index 000000000..4a33a4a19 --- /dev/null +++ b/lib/components/admin/panels/schemas/entry.jsx @@ -0,0 +1,91 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import A from '../../../a'; +import Lightbox from '../../../lightbox'; + +import schemaActions from '../../../../client/actions/schema'; + +export default class Entry extends Component { + getInitialState () { + return { + removing: false + }; + } + + onRemove (event) { + event.preventDefault(); + this.setState({ + removing: true + }); + } + + cancelRemove (event) { + event.preventDefault(); + this.setState({ + removing: false + }); + } + + confirmRemove (event) { + event.preventDefault(); + schemaActions.remove(this.props.schema._id); + this.setState({ + removing: false + }); + } + + renderRemoving () { + if (this.state.removing) { + const label = 'Are you sure you want to remove the schema '+this.props.schema.title+'?'; + const label1 = 'You will loose the schema and all entries in it'; + return ( + +
    {label}
    +
    {label1}
    + +
    + ); + } + } + + render () { + const schema = this.props.schema; + let viewLink = '/admin/schemas/'+schema.slug; + + return ( +
    +
    + archive +
    + + {this.renderRemoving()} +
    + ); + } +} + +Entry.propTypes = { + schema: React.PropTypes.object.isRequired +}; diff --git a/lib/components/admin/panels/schemas/index.jsx b/lib/components/admin/panels/schemas/index.jsx new file mode 100644 index 000000000..1cf390f03 --- /dev/null +++ b/lib/components/admin/panels/schemas/index.jsx @@ -0,0 +1,48 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import List from './list'; +import Filter from '../../../filter'; +import A from '../../../a'; + +import schemasStore from '../../../../client/stores/schemas'; + +export default class Schemas extends Component { + getInitialState () { + return { + opened: false, + schemas: this.context.schemas + }; + } + + getInitialCollections () { + return { + schemas: schemasStore.getCollection() + }; + } + + render () { + return ( +
    + +
    + +
    +
    + ); + } +} + +Schemas.contextTypes = { + schemas: React.PropTypes.array.isRequired +}; diff --git a/lib/components/admin/panels/schemas/list.jsx b/lib/components/admin/panels/schemas/list.jsx new file mode 100644 index 000000000..b6a85418f --- /dev/null +++ b/lib/components/admin/panels/schemas/list.jsx @@ -0,0 +1,19 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import Entry from './entry'; + +export default class Schemas extends Component { + renderEntry (schema) { + return ( + + ); + } + + render () { + return ( +
    + {this.props.data.map(this.renderEntry, this)} +
    + ); + } +} diff --git a/lib/components/admin/panels/settings.jsx b/lib/components/admin/panels/settings.jsx new file mode 100644 index 000000000..039517126 --- /dev/null +++ b/lib/components/admin/panels/settings.jsx @@ -0,0 +1,112 @@ +import Animate from '../../animate'; +import React from 'react'; +import {Component} from 'relax-framework'; +import OptionsList from '../../options-list'; +import Spinner from '../../spinner'; +import cx from 'classnames'; + +import {Types} from '../../../types'; +import settingsActions from '../../../client/actions/settings'; + +export default class Settings extends Component { + getInitialState () { + return { + settings: this.parseSettings(this.context.settings), + saving: false + }; + } + + onChange (id, value) { + this.state.settings[id] = value; + + this.setState({ + settings: this.state.settings + }); + } + + outSuccess () { + this.setState({ + success: false + }); + } + + submit (event) { + event.preventDefault(); + + clearTimeout(this.successTimeout); + this.setState({ + saving: true + }); + + settingsActions + .saveSettings(this.state.settings) + .then(() => { + this.setState({ + saving: false, + success: true + }); + this.successTimeout = setTimeout(this.outSuccess.bind(this), 3000); + }); + } + + renderSaving () { + if (this.state.saving) { + return ( + +
    + + Saving changes +
    +
    + ); + } else if (this.state.success) { + return ( + +
    + check + Saved successfuly +
    +
    + ); + } + } + + render () { + return ( +
    +
    + General Settings +
    +
    +
    + + Submit changes + {this.renderSaving()} +
    +
    +
    + ); + } +} + +Settings.options = [ + { + label: 'Site Title', + type: Types.String, + id: 'title', + default: '' + }, + { + label: 'Favicon', + type: Types.Image, + id: 'favicon', + props: { + width: 50, + height: 50 + } + } +]; + +Settings.contextTypes = { + settings: React.PropTypes.array.isRequired +}; diff --git a/lib/components/admin/panels/user-edit/index.jsx b/lib/components/admin/panels/user-edit/index.jsx new file mode 100644 index 000000000..60bbb36bc --- /dev/null +++ b/lib/components/admin/panels/user-edit/index.jsx @@ -0,0 +1,27 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import Breadcrumbs from '../../../breadcrumbs'; + +export default class UserEdit extends Component { + render () { + //const user = this.context.editUser; + + return ( +
    +
    + +
    +
    +
    + +
    +
    +
    + ); + } +} + +UserEdit.contextTypes = { + editUser: React.PropTypes.object.isRequired, + breadcrumbs: React.PropTypes.array.isRequired +}; diff --git a/lib/components/admin/panels/users/entry.jsx b/lib/components/admin/panels/users/entry.jsx new file mode 100644 index 000000000..b86443074 --- /dev/null +++ b/lib/components/admin/panels/users/entry.jsx @@ -0,0 +1,95 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import moment from 'moment'; +import A from '../../../a'; +import Lightbox from '../../../lightbox'; +import Utils from '../../../../utils'; + +import userActions from '../../../../client/actions/user'; + +export default class Entry extends Component { + getInitialState () { + return { + removing: false + }; + } + + onRemove (event) { + event.preventDefault(); + this.setState({ + removing: true + }); + } + + cancelRemove (event) { + event.preventDefault(); + this.setState({ + removing: false + }); + } + + confirmRemove (event) { + event.preventDefault(); + userActions.remove(this.props.user._id); + this.setState({ + removing: false + }); + } + + renderRemoving () { + if (this.state.removing) { + const label = 'Are you sure you want to remove the user '+this.props.user.name+'?'; + const label1 = 'This action cannot be reverted'; + return ( + +
    {label}
    +
    {label1}
    + +
    + ); + } + } + + render () { + const user = this.props.user; + let profileLink = '/admin/users/'+user.username; + let date = 'Registered - ' + moment(user.date).format('MMMM Do YYYY'); + let url = Utils.getGravatarImage(user.email, 70); + + return ( +
    +
    +
    + +
    +
    +
    +
    + {user.name} +
    +
    {date}
    +
    {'Username - '+user.username}
    +
    {'Email - '+user.email}
    + +
    + {this.renderRemoving()} +
    + ); + } +} + +Entry.propTypes = { + user: React.PropTypes.object.isRequired +}; diff --git a/lib/components/admin/panels/users/index.jsx b/lib/components/admin/panels/users/index.jsx new file mode 100644 index 000000000..10a27a0e9 --- /dev/null +++ b/lib/components/admin/panels/users/index.jsx @@ -0,0 +1,86 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import List from './list'; +import Filter from '../../../filter'; +import Lightbox from '../../../lightbox'; +import New from './new'; + +import userActions from '../../../../client/actions/user'; +import usersStore from '../../../../client/stores/users'; + +export default class Users extends Component { + getInitialState () { + return { + users: this.context.users, + search: (this.context.query && this.context.query.s) || '', + lightbox: false + }; + } + + getInitialCollections () { + return { + users: usersStore.getCollection() + }; + } + + onAddNew (newUser) { + userActions + .add(newUser) + .then(() => { + this.setState({ + lightbox: false + }); + }); + } + + addNewClick (event) { + event.preventDefault(); + this.setState({ + lightbox: true + }); + } + + closeLightbox () { + this.setState({ + lightbox: false + }); + } + + renderLightbox () { + if (this.state.lightbox) { + return ( + + + + ); + } + } + + render () { + return ( +
    + +
    + +
    + {this.renderLightbox()} +
    + ); + } +} + +Users.contextTypes = { + users: React.PropTypes.array.isRequired, + query: React.PropTypes.object +}; diff --git a/lib/components/admin/panels/users/list.jsx b/lib/components/admin/panels/users/list.jsx new file mode 100644 index 000000000..81b74b0cd --- /dev/null +++ b/lib/components/admin/panels/users/list.jsx @@ -0,0 +1,19 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import Entry from './entry'; + +export default class List extends Component { + renderEntry (user) { + return ( + + ); + } + + render () { + return ( +
    + {this.props.data.map(this.renderEntry, this)} +
    + ); + } +} diff --git a/lib/components/admin/panels/users/new.jsx b/lib/components/admin/panels/users/new.jsx new file mode 100644 index 000000000..554583ffd --- /dev/null +++ b/lib/components/admin/panels/users/new.jsx @@ -0,0 +1,70 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import OptionsList from '../../../options-list'; +import {Types} from '../../../../types'; + +export default class New extends Component { + getInitialState () { + return { + username: '', + password: '', + name: '', + email: '' + }; + } + + onChange (id, value) { + this.setState({ + [id]: value + }); + } + + onSubmit (event) { + event.preventDefault(); + this.props.onSubmit(this.state); + } + + render () { + return ( +
    + + + Add user + + ); + } +} + +New.options = [ + { + label: 'Username', + type: Types.String, + id: 'username', + default: '' + }, + { + label: 'Password', + type: Types.String, + id: 'password', + default: '', + props: { + password: true + } + }, + { + label: 'Name', + type: Types.String, + id: 'name', + default: '' + }, + { + label: 'Email', + type: Types.String, + id: 'email', + default: '' + } +]; + +New.propTypes = { + onSubmit: React.PropTypes.func.isRequired +}; diff --git a/lib/components/admin/top-menu/add-overlay/entry.jsx b/lib/components/admin/top-menu/add-overlay/entry.jsx new file mode 100644 index 000000000..33874988a --- /dev/null +++ b/lib/components/admin/top-menu/add-overlay/entry.jsx @@ -0,0 +1,34 @@ +import React from 'react'; +import {Component} from 'relax'; +import moment from 'moment'; +import cx from 'classnames'; +import A from '../../../a'; + +export default class Entry extends Component { + render () { + const page = this.props.page; + const editLink = '/admin/page/'+page.slug; + const published = page.state === 'published'; + const date = 'Created ' + moment(page.date).format('MMMM Do YYYY'); + + return ( + +
    + {published ? 'cloud_queue' : 'cloud_off'} +
    +
    +
    {page.title}
    +
    {date}
    +
    +
    + ); + } +} + +Entry.contextTypes = { + onClose: React.PropTypes.func.isRequired +}; + +Entry.propTypes = { + page: React.PropTypes.object.isRequired +}; diff --git a/lib/components/admin/top-menu/add-overlay/index.jsx b/lib/components/admin/top-menu/add-overlay/index.jsx new file mode 100644 index 000000000..5f5848c6e --- /dev/null +++ b/lib/components/admin/top-menu/add-overlay/index.jsx @@ -0,0 +1,58 @@ +import React from 'react'; +import {Component} from 'relax'; +import cx from 'classnames'; + +import NewPage from '../../panels/pages/manage'; +import List from './list'; + +export default class AddOverlay extends Component { + getInitialState () { + return { + content: 'new' + }; + } + + getChildContext () { + return { + onClose: this.props.onClose + }; + } + + addNewPage (pageData) { + + } + + changeContent (content, event) { + event.preventDefault(); + this.setState({ + content + }); + } + + renderContent () { + if (this.state.content === 'new') { + return ; + } else { + return ; + } + } + + render () { + return ( +
    +
    + Add new page + / + Open existing page +
    +
    + {this.renderContent()} +
    +
    + ); + } +} + +AddOverlay.childContextTypes = { + onClose: React.PropTypes.func.isRequired +}; diff --git a/lib/components/admin/top-menu/add-overlay/list.jsx b/lib/components/admin/top-menu/add-overlay/list.jsx new file mode 100644 index 000000000..dd1be3363 --- /dev/null +++ b/lib/components/admin/top-menu/add-overlay/list.jsx @@ -0,0 +1,33 @@ +import React from 'react'; +import {Component} from 'relax'; +import cx from 'classnames'; + +import Entry from './entry'; + +import pagesStore from '../../../../client/stores/pages'; + +export default class List extends Component { + getInitialState () { + return { + pages: [] + }; + } + + getInitialCollections () { + return { + pages: pagesStore.getCollection() + }; + } + + renderEntry (page) { + return ; + } + + render () { + return ( +
    + {this.state.pages.map(this.renderEntry, this)} +
    + ); + } +} diff --git a/lib/components/admin/top-menu/index.jsx b/lib/components/admin/top-menu/index.jsx new file mode 100644 index 000000000..3a1cf47f8 --- /dev/null +++ b/lib/components/admin/top-menu/index.jsx @@ -0,0 +1,168 @@ +import React from 'react'; +import {Component, Router} from 'relax-framework'; +import cx from 'classnames'; +import forEach from 'lodash.foreach'; + +import A from '../../a'; +import AddOverlay from './add-overlay'; + +import pageActions from '../../../client/actions/page'; +import tabsStore from '../../../client/stores/tabs'; +import tabActions from '../../../client/actions/tab'; + +export default class TopMenu extends Component { + getInitialState () { + return { + tabs: this.context.tabs + }; + } + + getInitialCollections () { + return { + tabs: tabsStore.getCollection({ + user: this.context.user._id + }) + }; + } + + publishPage (event) { + event.preventDefault(); + + this.context.page.state = 'published'; + pageActions.update(this.context.page); + } + + previewToggle (event) { + event.preventDefault(); + this.context.previewToggle(); + } + + changeDisplay (display, event) { + event.preventDefault(); + this.context.changeDisplay(display); + } + + onCloseTab (id, active, event) { + event.preventDefault(); + event.stopPropagation(); + + if (active) { + var to = '/admin/pages'; + forEach(this.state.tabs, (tab, ind) => { + if (tab._id === id) { + if (ind < this.state.tabs.length - 1) { + to = '/admin/page/'+this.state.tabs[ind+1].pageId.slug; + } else if (ind !== 0) { + to = '/admin/page/'+this.state.tabs[ind-1].pageId.slug; + } + return false; + } + }); + Router.prototype.navigate(to, {trigger: true}); + } + + tabActions.remove(id); + } + + onAddTabClick (event) { + event.preventDefault(); + this.context.addOverlay( + + ); + } + + renderTab (tab) { + const slug = tab.pageId.slug; + const title = tab.pageId.title; + const active = this.context.page && this.context.page.slug === slug; + const link = '/admin/page/'+slug; + + return ( + + {title} + close + + ); + } + + renderTabs () { + return ( +
    + {this.state.tabs && this.state.tabs.map(this.renderTab, this)} + + add + +
    + ); + } + + renderDisplayMenu () { + var positions = { + desktop: 0, + tablet: -35, + mobile: -70 + }; + var centerMenuStyle = { + left: positions[this.context.display] + }; + + return ( + + ); + } + + renderPageActions () { + // TODO check if editing a page (might be on the options page) + return ( +
    + {this.renderDisplayMenu()} + dashboard +
    + +
    + ); + } + + render () { + return ( +
    + {this.renderPageActions()} + {this.renderTabs()} +
    + ); + } +} + +TopMenu.propTypes = { + +}; + +TopMenu.contextTypes = { + tabs: React.PropTypes.array.isRequired, + user: React.PropTypes.object.isRequired, + page: React.PropTypes.object, + display: React.PropTypes.string.isRequired, + changeDisplay: React.PropTypes.func.isRequired, + previewToggle: React.PropTypes.func.isRequired, + editing: React.PropTypes.bool.isRequired, + lastDashboard: React.PropTypes.string.isRequired, + addOverlay: React.PropTypes.func.isRequired +}; diff --git a/lib/components/alert-box.jsx b/lib/components/alert-box.jsx new file mode 100644 index 000000000..034cc0cf1 --- /dev/null +++ b/lib/components/alert-box.jsx @@ -0,0 +1,13 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import cx from 'classnames'; + +export default class AlertBox extends Component { + render () { + return ( +
    + {this.props.children} +
    + ); + } +} diff --git a/lib/components/animate.jsx b/lib/components/animate.jsx new file mode 100644 index 000000000..495b55b95 --- /dev/null +++ b/lib/components/animate.jsx @@ -0,0 +1,28 @@ +import {Component} from 'relax-framework'; +import React from 'react'; +import Velocity from 'velocity-animate'; + +export default class Animate extends Component { + componentDidMount () { + var dom = React.findDOMNode(this); + const transition = 'transition.'+this.props.transition; + Velocity(dom, transition, { + duration: this.props.duration, + display: null + }); + } + + render () { + return this.props.children; + } +} + +Animate.propTypes = { + transition: React.PropTypes.string, + duration: React.PropTypes.number +}; + +Animate.defaultProps = { + transition: 'slideUpIn', + duration: 400 +}; diff --git a/lib/components/animateProps.jsx b/lib/components/animateProps.jsx new file mode 100644 index 000000000..1be42e3ca --- /dev/null +++ b/lib/components/animateProps.jsx @@ -0,0 +1,24 @@ +import {Component} from 'relax-framework'; +import React from 'react'; +import Velocity from 'velocity-animate'; + +export default class AnimateProps extends Component { + componentDidMount () { + var dom = React.findDOMNode(this); + Velocity(dom, this.props.props, this.props.options); + } + + render () { + return this.props.children; + } +} + +AnimateProps.propTypes = { + props: React.PropTypes.object, + options: React.PropTypes.object +}; + +AnimateProps.defaultProps = { + props: {}, + options: {} +}; diff --git a/lib/components/autocomplete.jsx b/lib/components/autocomplete.jsx new file mode 100644 index 000000000..1a82e1ae3 --- /dev/null +++ b/lib/components/autocomplete.jsx @@ -0,0 +1,64 @@ +import React from 'react'; +import {Component} from 'relax-framework'; + +export default class Autocomplete extends Component { + componentDidMount () { + const autoFocus = this.props.autoFocus; + + if (autoFocus) { + this.focus(); + } + } + + onInput (e) { + var str = React.findDOMNode(this.refs.editable).innerText; + + if (this.props.onChange) { + this.props.onChange(str); + } + } + + focus () { + var el = React.findDOMNode(this.refs.editable); + el.focus(); + if (typeof window.getSelection !== "undefined" && typeof document.createRange !== "undefined") { + var range = document.createRange(); + range.selectNodeContents(el); + range.collapse(false); + var sel = window.getSelection(); + sel.removeAllRanges(); + sel.addRange(range); + } else if (typeof document.body.createTextRange !== "undefined") { + var textRange = document.body.createTextRange(); + textRange.moveToElementText(el); + textRange.collapse(false); + textRange.select(); + } + } + + render () { + var suggestion = ''; + + if (this.props.suggestion !== '') { + suggestion = this.props.suggestion.slice(this.props.value.length); + } + + return ( +
    + {this.props.value} + {suggestion} +
    + ); + } +} + +Autocomplete.propTypes = { + autoFocus: React.PropTypes.bool, + onChange: React.PropTypes.func, + suggestion: React.PropTypes.string, + value: React.PropTypes.string.isRequired +}; + +Autocomplete.defaultProps = { + autoFocus: true +}; diff --git a/lib/components/border-picker.jsx b/lib/components/border-picker.jsx new file mode 100644 index 000000000..5d6c0e941 --- /dev/null +++ b/lib/components/border-picker.jsx @@ -0,0 +1,160 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import NumberInput from './number-input'; +import BorderStyle from './border-style'; +import ColorPicker from './color-palette-picker'; +import cloneDeep from 'lodash.clonedeep'; + +export default class BorderPicker extends Component { + getInitialState () { + return { + selected: 'center', + values: this.parseValue(this.props.value) + }; + } + + componentWillReceiveProps (nextProps) { + this.setState({ + values: this.parseValue(nextProps.value) + }); + } + + onInputChange (id, value) { + if (this.state.selected === 'center') { + this.state.values.top[id] = value; + this.state.values.right = cloneDeep(this.state.values.top); + this.state.values.bottom = cloneDeep(this.state.values.top); + this.state.values.left = cloneDeep(this.state.values.top); + this.state.values.equal = true; + } else { + this.state.values[this.state.selected][id] = value; + } + this.props.onChange(cloneDeep(this.state.values)); + } + + parseValue (value) { + var result = { + top: { + style: 'solid', + width: 1, + color: { + value: '#000000', + opacity: 100 + } + }, + left: { + style: 'solid', + width: 1, + color: { + value: '#000000', + opacity: 100 + } + }, + right: { + style: 'solid', + width: 1, + color: { + value: '#000000', + opacity: 100 + } + }, + bottom: { + style: 'solid', + width: 1, + color: { + value: '#000000', + opacity: 100 + } + }, + equal: false + }; + + if (value) { + result.top = value.top || result.top; + result.left = value.left || result.left; + result.right = value.right || result.right; + result.bottom = value.bottom || result.bottom; + } + + if (this.equal(result.top, result.right) && this.equal(result.top, result.bottom) && this.equal(result.top, result.left)) { + result.equal = true; + } else { + result.equal = false; + } + + return result; + } + + equal (comp1, comp2) { + return ( + comp1.style === comp2.style && + comp1.width === comp2.width && + comp1.color.value === comp2.color.value && + comp1.color.opacity === comp2.color.opacity + ); + } + + changeSelected (selected, event) { + event.preventDefault(); + this.setState({ + selected + }); + } + + renderToggleButton (pos, icon, active) { + var className = 'toggle ' + pos; + + if (this.state.selected === pos) { + className += ' selected'; + } + + if (active) { + className += ' active'; + } + + return ( +
    + {icon} +
    + ); + } + + render () { + var values = this.state.values; + var value = 0; + var inactive = false; + + if (this.state.selected !== 'center') { + value = values[this.state.selected]; + } else { + inactive = !values.equal; + value = values.top; + + if (inactive) { + value.style = 'none'; + } + } + + return ( +
    +
    + {this.renderToggleButton('top', 'border_top', !values.equal)} + {this.renderToggleButton('left', 'border_left', !values.equal)} + {this.renderToggleButton('center', 'border_outer', values.equal)} + {this.renderToggleButton('right', 'border_right', !values.equal)} + {this.renderToggleButton('bottom', 'border_bottom', !values.equal)} +
    +
    + + + +
    +
    + ); + } +} + +BorderPicker.propTypes = { + value: React.PropTypes.object.isRequired, + onChange: React.PropTypes.func.isRequired +}; diff --git a/lib/components/border-style.jsx b/lib/components/border-style.jsx new file mode 100644 index 000000000..498ee1447 --- /dev/null +++ b/lib/components/border-style.jsx @@ -0,0 +1,34 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import cx from 'classnames'; + +export default class BorderStyle extends Component { + onClick (type, event) { + event.preventDefault(); + this.props.onChange(type); + } + + renderOption (type) { + return ( +
    + {type === 'none' && close} +
    + ); + } + + render () { + return ( +
    + {this.renderOption('none')} + {this.renderOption('solid')} + {this.renderOption('dashed')} + {this.renderOption('dotted')} +
    + ); + } +} + +BorderStyle.propTypes = { + value: React.PropTypes.string.isRequired, + onChange: React.PropTypes.func.isRequired +}; diff --git a/lib/components/breadcrumbs.jsx b/lib/components/breadcrumbs.jsx new file mode 100644 index 000000000..2a42bcaf3 --- /dev/null +++ b/lib/components/breadcrumbs.jsx @@ -0,0 +1,42 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import A from './a'; + +export default class Breadcrumbs extends Component { + renderBreadcrumb (item, index) { + var props = { + className: 'breadcrumb' + }; + var result; + + if(item.link){ + props.href = item.link; + + result = ( + + {item.label} + + + ); + } + else { + result = ( + {item.label} + ); + } + + return result; + } + + render () { + return ( +
    + {this.props.data.map(this.renderBreadcrumb, this)} +
    + ); + } +} + +Breadcrumbs.propTypes = { + data: React.PropTypes.array.isRequired +}; diff --git a/lib/components/button.jsx b/lib/components/button.jsx new file mode 100644 index 000000000..512270bd7 --- /dev/null +++ b/lib/components/button.jsx @@ -0,0 +1,30 @@ +import {Component} from 'relax-framework'; +import React from 'react'; + +export default class Button extends Component { + onClick (event) { + event.preventDefault(); + + if (this.props.action === 'addElement') { + this.context.addElementAtSelected(this.props.actionProps); + } + } + + render () { + return ( + + {this.props.label} + + ); + } +} + +Button.contextTypes = { + addElementAtSelected: React.PropTypes.func +}; + +Button.propTypes = { + label: React.PropTypes.string.isRequired, + action: React.PropTypes.string.isRequired, + actionProps: React.PropTypes.object.isRequired +}; diff --git a/lib/components/checkbox.jsx b/lib/components/checkbox.jsx new file mode 100644 index 000000000..caad5853e --- /dev/null +++ b/lib/components/checkbox.jsx @@ -0,0 +1,28 @@ +import React from 'react'; +import {Component} from 'relax-framework'; + +export default class Checkbox extends Component { + toggle (event) { + event.preventDefault(); + + if(this.props.onChange){ + this.props.onChange(!this.props.value); + } + } + + render () { + var className = 'checkbox'+(this.props.value ? ' active' : ''); + + return ( + + + + + ); + } +} + +Checkbox.propTypes = { + value: React.PropTypes.bool.isRequired, + onChange: React.PropTypes.func.isRequired +}; diff --git a/lib/components/color-palette-picker/edit.jsx b/lib/components/color-palette-picker/edit.jsx new file mode 100644 index 000000000..a27f4db6f --- /dev/null +++ b/lib/components/color-palette-picker/edit.jsx @@ -0,0 +1,61 @@ +import {Component} from 'relax-framework'; +import React from 'react'; +import ColorPicker from 'react-colorpicker'; +import Lightbox from '../lightbox'; +import Input from '../input'; + +import colorsActions from '../../client/actions/colors'; + +export default class Edit extends Component { + getInitialState () { + return { + value: this.props.value || { + label: '', + value: '#ffffff' + } + }; + } + + closeEdit () { + this.props.onClose(); + } + + onEditColorChange (color) { + this.state.value.value = color.toHex(); + this.setState({ + value: this.state.value + }); + } + + onTitleChange (value) { + this.state.value.label = value; + this.setState({ + value: this.state.value + }); + } + + submit () { + if (this.state.value._id) { + colorsActions.update(this.state.value).then(() => this.closeEdit()); + } else { + colorsActions.add(this.state.value).then(() => this.closeEdit()); + } + } + + render () { + var isNew = this.state.value._id ? false : true; + var title = isNew ? 'Adding new color to palette' : 'Editing '+this.state.value.label; + var btn = isNew ? 'Add color to palette' : 'Change color'; + + return ( + + +
    + +
    + {btn} +
    + ); + } + +} diff --git a/lib/components/color-palette-picker/entry.jsx b/lib/components/color-palette-picker/entry.jsx new file mode 100644 index 000000000..ac72c64b7 --- /dev/null +++ b/lib/components/color-palette-picker/entry.jsx @@ -0,0 +1,93 @@ +import {Component} from 'relax-framework'; +import React from 'react'; +import OptionsMenu from '../options-menu'; +import cloneDeep from 'lodash.clonedeep'; +import cx from 'classnames'; + +import colorsActions from '../../client/actions/colors'; + +export default class Entry extends Component { + getInitialState () { + return { + options: false + }; + } + + edit () { + this.props.onEdit(this.props.color); + this.setState({ + options: false + }); + } + + duplicate () { + var duplicate = cloneDeep(this.props.color); + delete duplicate._id; + + colorsActions.add(duplicate); + + this.setState({ + options: false + }); + } + + remove () { + colorsActions.remove(this.props.color._id); + } + + openOptions (event) { + event.preventDefault(); + event.stopPropagation(); + this.setState({ + options: true + }); + } + + onMouseLeave () { + if (this.state.options) { + this.setState({ + options: false + }); + } + } + + onClick (event) { + event.preventDefault(); + this.props.onClick(this.props.color._id); + } + + renderOptionsMenu () { + if (this.state.options) { + return ( + + ); + } + } + + render () { + var style = { + backgroundColor: this.props.color.value + }; + + return ( +
    +
    + {this.props.color.label} +
    + more_horiz + {this.renderOptionsMenu()} +
    +
    + ); + } +} + +Entry.propTypes = { + color: React.PropTypes.object.isRequired, + onEdit: React.PropTypes.func.isRequired, + selected: React.PropTypes.bool.isRequired +}; diff --git a/lib/components/color-palette-picker/hex-edit.jsx b/lib/components/color-palette-picker/hex-edit.jsx new file mode 100644 index 000000000..7c737d1f2 --- /dev/null +++ b/lib/components/color-palette-picker/hex-edit.jsx @@ -0,0 +1,40 @@ +import {Component} from 'relax-framework'; +import React from 'react'; +import ColorPicker from 'react-colorpicker'; +import Lightbox from '../lightbox'; + +export default class HexEdit extends Component { + getInitialState () { + return { + value: this.props.value + }; + } + + onEditColorChange (color) { + this.setState({ + value: color.toHex() + }); + } + + onSubmit () { + this.props.onSubmit(this.state.value); + } + + render () { + return ( + +
    + +
    + Change it +
    + ); + } + +} + +HexEdit.propTypes = { + onClose: React.PropTypes.func.isRequired, + onSubmit: React.PropTypes.func.isRequired, + value: React.PropTypes.string.isRequired +}; diff --git a/lib/components/color-palette-picker/index.jsx b/lib/components/color-palette-picker/index.jsx new file mode 100644 index 000000000..d089c54d9 --- /dev/null +++ b/lib/components/color-palette-picker/index.jsx @@ -0,0 +1,128 @@ +import {Component} from 'relax-framework'; +import React from 'react'; +import NumberInput from '../number-input'; +import List from './list'; +import HexEdit from './hex-edit'; +import Colors from '../../colors'; +import clone from 'lodash.clone'; +import cx from 'classnames'; + +export default class ColorPicker extends Component { + getInitialState () { + return { + opened: false, + hexLightbox: false + }; + } + + onOpacityChange (opacity) { + var value = clone(this.props.value); + value.opacity = opacity; + this.props.onChange(value); + } + + onHexChange (event) { + var value = clone(this.props.value); + value.type = 'custom'; + value.value = event.target.value; + this.props.onChange(value); + } + + onEntryClick (id) { + var value = clone(this.props.value); + value.type = 'palette'; + value.value = id; + this.props.onChange(value); + this.setState({ + opened: false + }); + } + + toggleOpen (event) { + event.preventDefault(); + this.setState({ + opened: !this.state.opened + }); + } + + openEditColor (event) { + event.preventDefault(); + this.setState({ + hexLightbox: true + }); + } + closeEditColor () { + this.setState({ + hexLightbox: false + }); + } + submitEditColor (hex) { + var value = clone(this.props.value); + value.type = 'custom'; + value.value = hex; + this.props.onChange(value); + this.closeEditColor(); + } + + renderHexLightbox (hex) { + if (this.state.hexLightbox) { + return ; + } + } + + renderContent (color) { + if (this.state.opened) { + return ; + } else { + const hex = color.colr.toHex(); + const hexString = this.props.value.type === 'palette' ? hex : this.props.value.value; + + return ( +
    +
    +
    + +
    +
    + +
    + {this.renderHexLightbox(hex)} +
    + ); + } + } + + render () { + const color = Colors.getColor(this.props.value); + const colorString = Colors.getColorString(color); + const hsl = color.colr.toHslObject(); + var colorStyle = { + backgroundColor: colorString, + borderColor: colorString + }; + + return ( +
    60 && color.opacity > 50 && 'dark', this.props.className)}> +
    + {color.label} +
    {this.props.value.type === 'palette' ? 'invert_colors' : 'invert_colors_off'}
    +
    + {this.renderContent(color)} +
    + ); + } + +} + +ColorPicker.propTypes = { + value: React.PropTypes.object, + onChange: React.PropTypes.func +}; + +ColorPicker.defaultProps = { + value: { + type: 'custom', + value: '#000000', + opacity: 100 + } +}; diff --git a/lib/components/color-palette-picker/list.jsx b/lib/components/color-palette-picker/list.jsx new file mode 100644 index 000000000..05883afcd --- /dev/null +++ b/lib/components/color-palette-picker/list.jsx @@ -0,0 +1,94 @@ +import {Component} from 'relax-framework'; +import React from 'react'; +import Entry from './entry'; +import Edit from './edit'; +import cloneDeep from 'lodash.clonedeep'; + +import colorsStore from '../../client/stores/colors'; + +export default class List extends Component { + getInitialState () { + return { + colors: [], + editing: false + }; + } + + getInitialCollections () { + return { + colors: colorsStore.getCollection() + }; + } + + addNewOpen (event) { + event.preventDefault(); + this.setState({ + editing: true, + editingValue: this.props.selected.charAt(0) === '#' ? {label: '', value: this.props.selected} : false + }); + } + + editOpen (color) { + this.setState({ + editing: true, + editingValue: cloneDeep(color) + }); + } + + closeEdit () { + this.setState({ + editing: false + }); + } + + renderColorEntry (color) { + return ( + + ); + } + + renderList () { + if (this.state.colors.length > 0) { + return ( +
    + {this.state.colors.map(this.renderColorEntry, this)} +
    + ); + } else { + return ( +
    +
    invert_colors_off
    +
    You still don't have any colors in your palette!
    +
    + ); + } + } + + renderEditing () { + if (this.state.editing) { + return ( + + ); + } + } + + render () { + return ( +
    +
    + {this.renderList()} +
    +
    + add_circle_outline + Add new color +
    + {this.renderEditing()} +
    + ); + } +} + +List.propTypes = { + onEntryClick: React.PropTypes.func.isRequired, + selected: React.PropTypes.string.isRequired +}; diff --git a/lib/components/columns-manager.jsx b/lib/components/columns-manager.jsx new file mode 100644 index 000000000..47f5b9a2c --- /dev/null +++ b/lib/components/columns-manager.jsx @@ -0,0 +1,175 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import cx from 'classnames'; +import {Types} from '../types'; +import Utils from '../utils'; + +export default class ColumnsManager extends Component { + getInitialState () { + return { + selected: false + }; + } + + parseValue (value, idChanged = -1) { + return Utils.parseColumnsDisplay (value, this.context.selected.children.length, this.props.multiRows, idChanged); + } + + onClick (key, event) { + event.preventDefault(); + + if (this.state.selected === key) { + this.setState({ + selected: false + }); + } else { + this.setState({ + selected: key + }); + } + } + + onChange (id, value) { + var valueParsed = this.parseValue(this.props.value); + valueParsed[this.state.selected][id] = value; + const result = this.parseValue(valueParsed, this.state.selected); + this.props.onChange(result); + } + + renderColumn (id, value) { + var style = {}; + + if (value.width === 'custom') { + style.width = value.widthPerc+'%'; + } + + return ( +
    + ); + } + + renderChildren () { + var value = this.parseValue(this.props.value); + var children = [], i, numChildren = this.context.selected.children.length; + + for (i = 0; i < numChildren; i++) { + if (value[i].width === 'block') { + children.push(this.renderColumn(i, value[i])); + } else { + var columns = []; + for (i; i < numChildren; i++) { + if (value[i].width !== 'block' && !(columns.length > 0 && value[i].break)) { + columns.push(this.renderColumn(i, value[i])); + } else { + i--; + break; + } + } + children.push( +
    + {columns} +
    + ); + } + } + + return children; + } + + renderOptions () { + if (this.state.selected !== false) { + var value = this.parseValue(this.props.value); + var values = value[this.state.selected]; + var breakable = ( + this.props.multiRows && + values.width !== 'block' && + this.state.selected >= 2 && + this.state.selected < value.length - 1 && + value[this.state.selected - 1].width !== 'block' && + value[this.state.selected - 2].width !== 'block' + ); + + return ( +
    + + {breakable && } +
    + ); + } + } + + render () { + return ( +
    + {this.renderChildren()} + {this.renderOptions()} +
    + ); + } +} + +ColumnsManager.columnOptions = [ + { + label: 'Width', + type: Types.Select, + id: 'width', + props: { + labels: ['Block', 'Column auto', 'Column custom'], + values: ['block', 'auto', 'custom'] + }, + unlocks: { + custom: [ + { + label: 'Width (%)', + type: Types.Percentage, + id: 'widthPerc' + } + ] + } + } +]; + +ColumnsManager.columnOptionsSingleRow = [ + { + label: 'Width', + type: Types.Select, + id: 'width', + props: { + labels: ['Column auto', 'Column custom'], + values: ['auto', 'custom'] + }, + unlocks: { + custom: [ + { + label: 'Width (%)', + type: Types.Percentage, + id: 'widthPerc' + } + ] + } + } +]; + +ColumnsManager.breakOptions = [ + { + label: 'To next line', + type: Types.Boolean, + id: 'break', + default: false + } +]; + +ColumnsManager.contextTypes = { + selected: React.PropTypes.any.isRequired +}; + +ColumnsManager.propTypes = { + value: React.PropTypes.array.isRequired, + onChange: React.PropTypes.func.isRequired, + OptionsList: React.PropTypes.any.isRequired, + multiRows: React.PropTypes.bool +}; + +ColumnsManager.defaultProps = { + multiRows: true +}; diff --git a/lib/components/combobox.jsx b/lib/components/combobox.jsx new file mode 100644 index 000000000..53c2c0504 --- /dev/null +++ b/lib/components/combobox.jsx @@ -0,0 +1,74 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import forEach from 'lodash.foreach'; + +export default class Combobox extends Component { + getInitialState () { + return { + opened: false + }; + } + + toggle () { + this.setState({ + opened: !this.state.opened + }); + } + + optionClicked ( value, event ) { + event.preventDefault(); + + if (this.props.onChange) { + this.props.onChange(value); + } + + this.setState({ + opened: false + }); + } + + renderOption (option, i) { + return ( +
    + {option} +
    + ); + } + + render () { + var className = 'combobox-holder' + (this.state.opened ? ' opened' : ''); + + var label = ''; + forEach(this.props.values, (value, key) => { + if (this.props.value === value) { + label = this.props.labels[key]; + } + }); + + return ( +
    +
    +
    +
    {label}
    +
    + +
    +
    +
    + {this.props.labels.map(this.renderOption, this)} +
    +
    +
    + ); + } +} + +Combobox.propTypes = { + labels: React.PropTypes.array.isRequired, + values: React.PropTypes.array.isRequired, + value: React.PropTypes.string.isRequired, + onChange: React.PropTypes.func.isRequired +}; diff --git a/lib/components/complement-menu.jsx b/lib/components/complement-menu.jsx new file mode 100644 index 000000000..803bcb3c1 --- /dev/null +++ b/lib/components/complement-menu.jsx @@ -0,0 +1,17 @@ +import {Component} from 'relax-framework'; +import React from 'react'; +import cx from 'classnames'; + +export default class ComplementMenu extends Component { + render () { + return ( +
    + {this.props.children} +
    + ); + } +} + +ComplementMenu.propTypes = { + className: React.PropTypes.string +}; diff --git a/lib/components/component.jsx b/lib/components/component.jsx new file mode 100644 index 000000000..564970393 --- /dev/null +++ b/lib/components/component.jsx @@ -0,0 +1,60 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import {Droppable} from './drag'; + +import stylesStore from '../client/stores/styles'; + +export default class ElementComponent extends Component { + + getInitialModels () { + var models = {}; + + if (this.constructor.settings.styles && this.props.style && typeof this.props.style === 'string' && this.props.style !== '') { + models.style = stylesStore.getModel(this.props.style); + } + + return models; + } + + componentWillReceiveProps (nextProps) { + if (this.constructor.settings.styles) { + if (typeof nextProps.style === 'object') { + this.unsetModels(['style']); + this.setState({ + style: nextProps.style + }); + } else { + if (nextProps.style && nextProps.style !== this.props.style && nextProps.style !== '') { + this.setModels({ + style: stylesStore.getModel(nextProps.style) + }); + } else if (!nextProps.style || nextProps.style === '' || nextProps.style === null) { + this.unsetModels(['style']); + this.setState({ + style: false + }); + } + } + } + } + + renderContent (customProps) { + if (this.context.editing) { + var dropInfo = { + id: this.props.element.id + }; + + return ( + + {this.props.children} + + ); + } else { + return this.props.children; + } + } +} + +ElementComponent.contextTypes = { + editing: React.PropTypes.bool.isRequired +}; diff --git a/lib/components/corners-picker.jsx b/lib/components/corners-picker.jsx new file mode 100644 index 000000000..584163f67 --- /dev/null +++ b/lib/components/corners-picker.jsx @@ -0,0 +1,132 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import NumberInput from './number-input'; + +export default class CornersPicker extends Component { + getInitialState () { + return { + selected: 'center', + values: this.parseValue(this.props.value) + }; + } + + componentWillReceiveProps (nextProps) { + this.setState({ + values: this.parseValue(nextProps.value) + }); + } + + onInputChange (value) { + if (this.state.selected === 'center') { + this.state.values.tl = value; + this.state.values.tr = value; + this.state.values.br = value; + this.state.values.bl = value; + } else { + this.state.values[this.state.selected] = value; + } + this.props.onChange(this.getValuesString(this.state.values)); + } + + getValuesString (values) { + return values.tl+'px '+values.tr+'px '+values.br+'px '+values.bl+'px'; + } + + parseValue (value) { + var values = value.split(' '); + var result = { + tl: 0, + bl: 0, + tr: 0, + br: 0, + equal: false + }; + + if (values.length === 1) { + var parsedValue = parseInt(values[0], 10); + result.tl = parsedValue; + result.br = parsedValue; + result.bl = parsedValue; + result.tr = parsedValue; + } else if (values.length === 2) { + result.tl = parseInt(values[0], 10); + result.tr = parseInt(values[1], 10); + result.br = parseInt(values[0], 10); + result.bl = parseInt(values[1], 10); + } else if (values.length === 4) { + result.tl = parseInt(values[0], 10); + result.tr = parseInt(values[1], 10); + result.br = parseInt(values[2], 10); + result.bl = parseInt(values[3], 10); + } + + if (result.tl === result.tr && result.tl === result.br && result.tl === result.bl) { + result.equal = true; + } else { + result.equal = false; + } + + return result; + } + + changeSelected (selected, event) { + event.preventDefault(); + this.setState({ + selected + }); + } + + renderToggleButton (pos, active) { + var className = 'toggle ' + pos; + + if (this.state.selected === pos) { + className += ' selected'; + } + + if (active) { + className += ' active'; + } + + return ( +
    + {pos === 'center' ? link : } +
    + ); + } + + render () { + var className = 'corners-picker type-' + this.props.type; + var values = this.state.values; + var value = 0; + var inactive = false; + + if (this.state.selected !== 'center') { + value = values[this.state.selected]; + } else { + inactive = !values.equal; + value = values.equal ? values.tl : Math.round((values.tl+values.tr+values.br+values.bl)/4); + } + + return ( +
    +
    + {this.renderToggleButton('tl', !values.equal)} + {this.renderToggleButton('bl', !values.equal)} + {this.renderToggleButton('center', values.equal)} + {this.renderToggleButton('tr', !values.equal)} + {this.renderToggleButton('br', !values.equal)} +
    +
    +
    Value
    + +
    +
    + ); + } +} + +CornersPicker.propTypes = { + value: React.PropTypes.string.isRequired, + onChange: React.PropTypes.func.isRequired, + type: React.PropTypes.string.isRequired +}; diff --git a/lib/components/drag.jsx b/lib/components/drag.jsx new file mode 100644 index 000000000..c11aea85a --- /dev/null +++ b/lib/components/drag.jsx @@ -0,0 +1,637 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import forEach from 'lodash.foreach'; +import merge from 'lodash.merge'; +import Utils from '../utils'; +import AnimateProps from './animateProps'; +import Velocity from 'velocity-animate'; +import cx from 'classnames'; + +var LEFT_BUTTON = 0; +var draggingData = {}; +var dragReport = { + dropInfo: false +}; +var droppableOrientation = 'vertical'; + +export class Draggable extends Component { + getInitialState () { + this.onMouseUpListener = this.onMouseUp.bind(this); + this.onMouseMoveListener = this.onMouseMove.bind(this); + + return { + dragging: false + }; + } + + onMouseUp () { + document.removeEventListener('mouseup', this.onMouseUpListener); + document.removeEventListener('mousemove', this.onMouseMoveListener); + } + + onMouseMove (event) { + event.preventDefault(); + + this.onMouseUp(); + + var element = React.findDOMNode(this); + + var elementOffset = Utils.getOffsetRect(element); + var width = elementOffset.width; + + // Change state + this.setState({ + dragging: true + }); + + // Dragging data + draggingData = { + children: this.props.children, + elementOffset: elementOffset, + elementWidth: width, + mouseX: event.pageX, + mouseY: event.pageY, + type: this.props.type + }; + + dragReport.dragInfo = this.props.dragInfo; + + if(this.props.droppableOn){ + draggingData.droppableOn = this.props.droppableOn; + } + + // Parent events + if (this.props && this.props.onStartDrag) { + this.props.onStartDrag(); + } else if (this.context && this.context.onStartDrag) { + this.context.onStartDrag(); + } else { + console.log("onStartDrag callback was no set on draggable object"); + } + + } + + onMouseDown (event) { + if (event.button === LEFT_BUTTON) { + let draggable = !(this.props.dragSelected === false && this.context.selected.id === this.props.dragInfo.id); + event.stopPropagation(); + + if (draggable) { + document.addEventListener('mouseup', this.onMouseUpListener); + document.addEventListener('mousemove', this.onMouseMoveListener); + } + } + } + + render () { + var props = { + className: (this.props.children.props.className || '')+' draggable', + draggable: 'false', + onMouseDown: this.onMouseDown.bind(this) + }; + + if (this.props.onClick) { + props.onClick = this.props.onClick; + } + + return React.cloneElement(this.props.children, props); + } +} + +Draggable.contextTypes = { + selected: React.PropTypes.any, + onStartDrag: React.PropTypes.func +}; + +Draggable.propTypes = { + type: React.PropTypes.string.isRequired, + dragInfo: React.PropTypes.object.isRequired, + droppableOn: React.PropTypes.string, + onStartDrag: React.PropTypes.func, + onClick: React.PropTypes.func +}; + +class Marker extends Component { + animateIn () { + var animateObj = {}; + + if (droppableOrientation === 'vertical') { + animateObj.height = '7px'; + } else { + animateObj.width = '7px'; + } + + Velocity(React.findDOMNode(this), animateObj, { duration: 400, easing: "easeOutExpo" }); + } + + componentDidMount () { + this.animateInterval = setTimeout(this.animateIn.bind(this), 50); + } + + componentWillUnmount () { + clearTimeout(this.animateInterval); + } + + render () { + var style = { + height: droppableOrientation === 'vertical' ? 0 : 'auto', + width: droppableOrientation === 'vertical' ? '100%' : 0, + backgroundColor: '#33CC33', + opacity: '0.8' + }; + + if (droppableOrientation === 'horizontal') { + style.display = 'table-cell'; + } + + return ( +
    + ); + } +} + + +export class Dragger extends Component { + getInitialState () { + return { + top: draggingData.elementOffset.top + (this.props.offset && this.props.offset.top ? this.props.offset.top : 0), + left: draggingData.elementOffset.left + (this.props.offset && this.props.offset.left ? this.props.offset.left : 0) + }; + } + + componentDidMount () { + super.componentDidMount(); + + this.onMouseUpListener = this.onMouseUp.bind(this); + this.onMouseMoveListener = this.onMouseMove.bind(this); + + let node = React.findDOMNode(this); + + let relativeX = draggingData.mouseX - draggingData.elementOffset.left; + let relativeY = draggingData.mouseY - draggingData.elementOffset.top; + node.style.transformOrigin = relativeX+'px '+relativeY+'px'; + + Velocity(React.findDOMNode(this), { + scaleX: '0.5', + scaleY: '0.5', + opacity: '0.7' + }, { duration: 500, easing: "easeOutExpo" }); + + document.addEventListener('mouseup', this.onMouseUpListener); + document.addEventListener('mousemove', this.onMouseMoveListener); + } + + onMouseUp (event) { + document.removeEventListener('mouseup', this.onMouseUpListener); + document.removeEventListener('mousemove', this.onMouseMoveListener); + + // Parent events + if (this.props.onStopDrag) { + this.props.onStopDrag(); + } + else { + console.log("onStopDrag callback was no set on dragger object"); + } + } + + onMouseMove (event) { + event.preventDefault(); + + var deltaX = event.pageX - draggingData.mouseX + draggingData.elementOffset.left; + var deltaY = event.pageY - draggingData.mouseY + draggingData.elementOffset.top; + + this.setState({ + top: deltaY + (this.props.offset && this.props.offset.top ? this.props.offset.top : 0), + left: deltaX + (this.props.offset && this.props.offset.left ? this.props.offset.left : 0) + }); + } + + render () { + var style = { + position: 'absolute', + width: draggingData.elementWidth+'px', + top: this.state.top+'px', + left: this.state.left+'px', + pointerEvents: 'none', + boxShadow: '0px 0px 20px 0px rgba(0, 0, 0, 0.5)', + zIndex: 20 + }; + + return ( +
    + {draggingData.children} +
    + ); + } +} + + +export class Droppable extends Component { + + getInitialState () { + this.onMouseMoveListener = this.onMouseMove.bind(this); + this.onMouseUpListener = this.onMouseUp.bind(this); + + return { + overed: false, + closeToMargin: false + }; + } + + componentWillReceiveProps (nextProps) { + if (!nextProps.dragging) { + this.removeOrderingEvents(); + + this.setState({ + entered: false, + overed: false + }); + } + } + + componentDidMount () { + const containerRect = React.findDOMNode(this).getBoundingClientRect(); + + if (containerRect.left < 40) { + if (!this.state.closeToMargin) { + this.setState({ + closeToMargin: true + }); + } + } else if (this.state.closeToMargin) { + this.setState({ + closeToMargin: false + }); + } + } + + getChildContext () { + var childContext = { + dropHighlight: 'none' + }; + + if (this.context.dragging) { + if (this.droppableHere()) { + if (this.props.orientation && this.props.orientation === 'horizontal') { + childContext.dropHighlight = 'horizontal'; + } else { + childContext.dropHighlight = 'vertical'; + } + } else if (this.draggingSelf()) { + childContext.dropBlock = true; + } + } + + return childContext; + } + + onMouseEnter (event) { + if (this.state.entered) { + return; + } + + // Ordering + var order = false; + if (this.props.children && (this.props.children instanceof Array && this.props.children.length > 0)) { + var elements = React.findDOMNode(this).children; + + if (elements.length > 0) { + + // store children positions + this.childrenData = []; + var domPosition = 0; + forEach(elements, (child) => { + if (this.props.selectionChildren && child.className.indexOf(this.props.selectionChildren) === -1) { + domPosition ++; + return true; + } + order = true; + + let position = Utils.getOffsetRect(child); + let width = position.width; + let height = position.height; + + this.childrenData.push({position, width, height, domPosition}); + + domPosition ++; + }); + } + } + + this.setState({ + entered: true, + order: order, + overed: !order + }); + + if (order) { + this.addOrderingEvents(); + this.onMouseMove(event); + } else { + dragReport.dropInfo = this.props.dropInfo; + } + } + + onMouseLeave (event) { + this.removeOrderingEvents(); + + if (dragReport.dropInfo && dragReport.dropInfo.id === this.props.dropInfo.id) { + dragReport.dropInfo = false; + } + + this.setState({ + entered: false, + overed: false + }); + } + + onMouseMove (event) { + var position = -1; + const hitSpace = this.props.hitSpace; + + var mousePosition = this.props.orientation === 'horizontal' ? event.pageX : event.pageY; + + forEach(this.childrenData, (child, index) => { + + if (index === 0) { + let firstPosition = this.props.orientation === 'horizontal' ? child.position.left : child.position.top; + let secondPosition = this.props.orientation === 'horizontal' ? child.position.left+hitSpace : child.position.top+hitSpace; + + if (mousePosition > firstPosition && mousePosition < secondPosition) { + position = index; + this.draggerPosition = child.domPosition; + return false; + } + } + + var firstPosition, secondPosition; + if (index === this.childrenData.length - 1) { + firstPosition = this.props.orientation === 'horizontal' ? child.position.left+child.width-hitSpace : child.position.top+child.height-hitSpace; + secondPosition = this.props.orientation === 'horizontal' ? child.position.left+child.width : child.position.top+child.height; + } else { + firstPosition = this.props.orientation === 'horizontal' ? child.position.left+child.width-hitSpace/2 : child.position.top+child.height-hitSpace/2; + secondPosition = this.props.orientation === 'horizontal' ? child.position.left+child.width+hitSpace/2 : child.position.top+child.height+hitSpace/2; + } + + if (mousePosition > firstPosition && mousePosition < secondPosition) { + position = index+1; + this.draggerPosition = child.domPosition + 1; + return false; + } + }); + + if (position !== -1 && !this.state.overed) { + if (dragReport.dropInfo === false) { + this.setState({ + overed: true, + position + }); + this.props.dropInfo.position = position; + dragReport.dropInfo = this.props.dropInfo; + droppableOrientation = this.props.orientation; + + event.stopPropagation(); + } + } + if (position === -1 && this.state.overed) { + this.setState({ + overed: false, + position: false + }); + + if (dragReport.dropInfo && dragReport.dropInfo.id === this.props.dropInfo.id) { + dragReport.dropInfo = false; + } + } + } + + onMouseUp (event) { + + } + + addOrderingEvents () { + document.addEventListener('mousemove', this.onMouseMoveListener); + document.addEventListener('mouseup', this.onMouseUpListener); + } + + removeOrderingEvents () { + document.removeEventListener('mousemove', this.onMouseMoveListener); + document.removeEventListener('mouseup', this.onMouseUpListener); + } + + draggingSelf () { + return this.props.dropInfo.id && dragReport.dragInfo.id && this.props.dropInfo.id === dragReport.dragInfo.id; + } + + droppableHere () { + var is = true; + + var dropBlock = this._reactInternalInstance._context && this._reactInternalInstance._context.dropBlock; // # TODO modify when react passes context from owner-based to parent-based (0.14?) + if (this.draggingSelf() || dropBlock) { + return false; + } + + // Droppable restrictions + if (this.props.accepts) { + if (this.props.accepts !== 'any' && this.props.accepts !== draggingData.type) { + is = false; + } + } else if (this.props.rejects) { + if (this.props.rejects === 'any' || this.props.rejects === draggingData.type) { + is = false; + } + } + + // Dragging restrictions + if (is && draggingData.droppableOn) { + if (draggingData.droppableOn !== 'any' && this.props.type !== draggingData.droppableOn) { + is = false; + } + } + + return is; + } + + getEvents () { + if (this.context.dragging && this.droppableHere()) { + return { + onMouseOver: this.onMouseEnter.bind(this), + onMouseLeave: this.onMouseLeave.bind(this) + }; + } + } + + addSpotClick (position, event) { + event.preventDefault(); + this.context.openElementsMenu({ + targetId: this.props.dropInfo.id || 'body', + targetType: this.props.type, + targetPosition: position, + container: React.findDOMNode(this.refs['spot'+position]), + accepts: this.props.accepts, + rejects: this.props.rejects + }); + } + + renderPlaceholderContent () { + if (this.state.overed) { + let props = { + scaleX: '150%', + scaleY: '150%' + }; + let options = { + duration: 600, + loop: true + }; + return ( + + add_circle + + ); + } else { + return ( +
    + Drop elements here or + + click to add + +
    + ); + } + } + + renderPlaceholder () { + if (this.props.placeholder) { + return ( +
    + {this.renderPlaceholderContent()} +
    + ); + } + } + + renderMark (position) { + let vertical = this.props.orientation && this.props.orientation === 'horizontal'; + let active = this.context.elementsMenuSpot === position; + + return ( +
    + + + + add + + +
    + ); + } + + render () { + var children = this.props.children; + var hasChildren = children && (children instanceof Array && children.length > 0); + + var style = { + backgroundColor: this.state.overed && !this.state.order && !this.props.placeholder ? '#33CC33' : 'transparent', + minHeight: hasChildren ? 0 : this.props.minHeight, + minWidth: hasChildren ? 0 : this.props.minWidth, + position: 'relative' + }; + if (this.props.style) { + merge(style, this.props.style); + } + + if (this.state.overed && this.state.order && this.state.position !== false) { + children = hasChildren ? children.slice(0) : [this.props.children]; + + let marker = ( + + ); + + children.splice(this.draggerPosition, 0, marker); + } else if (hasChildren && this.context.selected.id === this.props.dropInfo.id && !this.context.dragging) { + var tempChildren = [ + this.renderMark(0) + ]; + + forEach(children, (child, index) => { + tempChildren.push(child); + tempChildren.push(this.renderMark(index+1)); + }); + + children = tempChildren; + } + + return ( +
    + {hasChildren ? children : this.renderPlaceholder()} +
    + ); + } +} + +Droppable.propTypes = { + orientation: React.PropTypes.string, + dropInfo: React.PropTypes.object.isRequired, + hitSpace: React.PropTypes.number.isRequired, + style: React.PropTypes.object, + minHeight: React.PropTypes.number, + accepts: React.PropTypes.any, + rejects: React.PropTypes.any, + type: React.PropTypes.string, + placeholder: React.PropTypes.bool +}; + +Droppable.defaultProps = { + orientation: 'vertical', + minHeight: 150, + minWidth: 50, + hitSpace: 18, + placeholder: false +}; + +Droppable.contextTypes = { + dragging: React.PropTypes.bool.isRequired, + dropBlock: React.PropTypes.bool, + selected: React.PropTypes.any, + openElementsMenu: React.PropTypes.func.isRequired, + elementsMenuSpot: React.PropTypes.number +}; + +Droppable.childContextTypes = { + dropHighlight: React.PropTypes.string.isRequired, + dropBlock: React.PropTypes.bool +}; + + +export class DragRoot extends Component { + constructor (props, children) { + super(props, children); + } + + onStartDrag () { + this.setState({ + dragging: true + }); + } + + onStopDragEvent () { + this.setState({ + dragging: false + }); + + if (this.draggedComponent) { + this.draggedComponent(dragReport); + dragReport.dropInfo = false; + } else { + console.log('draggedComponent not implemented on drag root extended component'); + } + } + + renderDragger (offset = {}) { + if (this.state && this.state.dragging) { + return ( + + ); + } + } +} diff --git a/lib/components/element.jsx b/lib/components/element.jsx new file mode 100644 index 000000000..81b6caffe --- /dev/null +++ b/lib/components/element.jsx @@ -0,0 +1,253 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import forEach from 'lodash.foreach'; +import merge from 'lodash.merge'; +import {Droppable, Draggable} from './drag'; +import Utils from '../utils'; +import Velocity from 'velocity-animate'; +import cx from 'classnames'; + +export default class Element extends Component { + getInitialState () { + if (this.context.editing && this.isClient()) { + this.animationEditingBind = this.animationEditing.bind(this); + window.addEventListener('animateElements', this.animationEditingBind); + } + + return { + offset: {top: 0}, + animation: this.props.element.animation && this.props.element.animation.use, + animated: false, + animatedEditing: false + }; + } + + componentWillReceiveProps (nextProps) { + if (this.context.editing && this.state.animation !== (this.props.element.animation && this.props.element.animation.use)) { + this.setState({ + animation: this.props.element.animation && this.props.element.animation.use + }); + } + } + + componentDidMount () { + this.state.offset = this.getOffset(); + + if ((!this.context.editing && this.state.animation) || this.props.onEnterScreen) { + this.onScrollBind = this.onScroll.bind(this); + window.addEventListener('scroll', this.onScrollBind); + this.onScroll(); + } + } + + componentWillUnmount () { + if (this.onScrollBind) { + window.removeEventListener('scroll', this.onScrollBind); + } + if (this.animationEditingBind) { + window.removeEventListener('animateElements', this.animationEditingBind); + } + if (this.animationTimeout) { + clearTimeout(this.animationTimeout); + } + } + + animate () { + var dom = React.findDOMNode(this); + var animation = this.props.element.animation; + this.state.animated = true; + this.state.animatedEditing = false; + Velocity(dom, animation.effect, { + duration: animation.duration, + display: null + }); + } + + animationInit () { + if (this.state.animation) { + var animation = this.props.element.animation; + this.animationTimeout = setTimeout(this.animate.bind(this), animation.delay); + } + } + + animationEditing () { + if (this.state.animation) { + this.setState({ + animated: false, + animatedEditing: true + }); + this.animationInit(); + } + } + + onScroll () { + var dom = React.findDOMNode(this); + var rect = dom.getBoundingClientRect(); + + if ( (rect.top <= 0 && rect.bottom >= 0) || (rect.top > 0 && rect.top < window.outerHeight) ) { + if (this.state.animation) { + this.animationInit(); + } + if (this.props.onEnterScreen) { + this.props.onEnterScreen(); + } + window.removeEventListener('scroll', this.onScrollBind); + } + } + + onElementClick (event) { + event.stopPropagation(); + this.context.selectElement(this.props.element.id); + } + + getOffset () { + var dom = React.findDOMNode(this); + return Utils.getOffsetRect(dom); + } + + onMouseOver (event) { + if (!this.context.dragging) { + event.stopPropagation(); + clearTimeout(this.outTimeout); + if (this.props.element.id !== this.context.overedElement.id && this.props.element.id !== this.context.selected.id) { + var offset = this.getOffset(); + this.context.overElement(this.props.element.id); + this.state.offset = offset; + } + } + } + + onMouseOut () { + if (!this.context.dragging && this.props.element.id === this.context.overedElement.id) { + this.outTimeout = setTimeout(this.selectOut.bind(this), 50); + } + } + + selectOut () { + this.context.outElement(this.props.element.id); + } + + renderContent () { + if (this.props.settings.drop && !this.props.settings.drop.customDropArea && this.context.editing) { + var dropInfo = { + id: this.props.element.id + }; + + return ( + + {this.props.children} + + ); + } else { + return this.props.children; + } + } + + renderHighlight () { + if (typeof this.props.element.id !== 'string') { + var className; + var dropHighlight = this._reactInternalInstance._context.dropHighlight; // # TODO modify when react passes context from owner-based to parent-based (0.14?) + + if (!this.context.dragging && (this.props.element.id === this.context.overedElement.id || this.props.element.id === this.context.selected.id)) { + var elementType = this.props.element.tag; + var element = this.context.elements[elementType]; + + let selected = this.props.element.id === this.context.selected.id; + let inside = this.state.offset.top <= 65 || (this.props.style && this.props.style.overflow === 'hidden'); + let subComponent = this.props.element.subComponent; + + return ( +
    +
    + {element.settings.icon.content} + {this.props.element.label || elementType} +
    +
    + ); + } else if (dropHighlight !== 'none') { + className = 'element-drop-highlight '+dropHighlight; + return ( +
    + ); + } + } + } + + render () { + var props = {}; + forEach(this.props, (prop, key) => { + if (key !== 'tag' && key !== 'children' && key !== 'settings' && key !== 'element' && key !== 'onEnterScreen') { + props[key] = prop; + } + }); + + if (this.context.editing && this.props.settings.drag) { + if ((!this.context.dragging && (this.props.element.id === this.context.overedElement.id || this.props.element.id === this.context.selected.id)) || this.context.dragging) { + props.style = props.style || {}; + props.style.position = props.style.position || 'relative'; + } + + if (this.state.animatedEditing && this.state.animation && !this.state.animated) { + props.style = props.style || {}; + props.style.opacity = 0; + } + + if (this.props.element.subComponent) { + return ( + + {this.renderContent()} + {this.renderHighlight()} + + ); + } else { + var draggableProps = merge({ + dragInfo: { + type: 'move', + id: this.props.element.id + }, + onClick: this.onElementClick.bind(this), + type: this.props.element.tag + }, this.props.settings.drag); + + return ( + + + {this.renderContent()} + {this.renderHighlight()} + + + ); + } + } else { + if (this.state.animation && !this.state.animated) { + props.style = props.style || {}; + props.style.opacity = 0; + } + + return ( + + {this.renderContent()} + + ); + } + } +} + +Element.propTypes = { + tag: React.PropTypes.string.isRequired, + element: React.PropTypes.object.isRequired, + settings: React.PropTypes.object.isRequired, + onEnterScreen: React.PropTypes.func +}; + +Element.contextTypes = { + selected: React.PropTypes.any, + selectElement: React.PropTypes.func, + dragging: React.PropTypes.bool, + elements: React.PropTypes.object, + overElement: React.PropTypes.func, + outElement: React.PropTypes.func, + overedElement: React.PropTypes.any, + editing: React.PropTypes.bool.isRequired, + dropHighlight: React.PropTypes.string +}; diff --git a/lib/components/elements/button/classes.js b/lib/components/elements/button/classes.js new file mode 100644 index 000000000..9475e7e39 --- /dev/null +++ b/lib/components/elements/button/classes.js @@ -0,0 +1,26 @@ +import jss from '../../../react-jss'; + +export default jss.createRules({ + holder: { + textAlign: 'center' + }, + button: { + color: '#ffffff', + backgroundColor: '#282828', + borderRadius: '3px 3px 3px 3px', + padding: '11px 20px 11px 20px', + maxWidth: '250px', + display: 'inline-block', + ':hover': { + color: '#282828', + backgroundColor: '#ffffff' + } + }, + sided: { + display: 'block', + '>div': { + display: 'table-cell', + verticalAlign: 'middle' + } + } +}); diff --git a/lib/components/elements/button/index.jsx b/lib/components/elements/button/index.jsx new file mode 100644 index 000000000..4696f5195 --- /dev/null +++ b/lib/components/elements/button/index.jsx @@ -0,0 +1,136 @@ +import React from 'react'; +import Component from '../../component'; +import Element from '../../element'; +import styles from '../../../styles'; +import cx from 'classnames'; +import forEach from 'lodash.foreach'; + +import settings from './settings'; +import style from './style'; +import classes from './classes'; +import propsSchema from './props-schema'; + +export default class Button extends Component { + + componentWillReceiveProps (nextProps) { + if (this.context.editing && this.context.selected && this.context.selected.id === this.props.element.id) { + // Check if layout changed + if (nextProps.layout !== this.props.layout) { + // 'text', 'icontext', 'texticon', 'icon' + + let newChildren = []; + + let textChild = false; + let iconChild = false; + + if (nextProps.layout === 'text' || nextProps.layout === 'texticon' || nextProps.layout === 'icontext') { + forEach(this.props.element.children, (child) => { + if (child.tag === 'TextBox') { + textChild = child; + } + }); + + if (!textChild) { + textChild = { + tag: 'TextBox', + children: 'Button text', + subComponent: true + }; + } + } + + if (nextProps.layout === 'icon' || nextProps.layout === 'texticon' || nextProps.layout === 'icontext') { + forEach(this.props.element.children, (child) => { + if (child.tag === 'Icon') { + iconChild = child; + } + }); + + if (!iconChild) { + iconChild = { + tag: 'Icon', + subComponent: true + }; + } + } + + if (iconChild && textChild) { + if (nextProps.layout === 'icon' || nextProps.layout === 'icontext') { + newChildren.push(iconChild); + if (nextProps.layout === 'icontext') { + newChildren.push(textChild); + } + } else if (nextProps.layout === 'text' || nextProps.layout === 'texticon') { + newChildren.push(textChild); + if (nextProps.layout === 'texticon') { + newChildren.push(iconChild); + } + } + } else { + newChildren.push(iconChild || textChild); + } + + // Change it + this.context.elementContentChange(newChildren); + } + } + } + + renderChildren () { + if (this.props.arrange === 'blocks' || this.props.layout === 'text' || this.props.layout === 'icon') { + return this.props.children; + } else { + return ( +
    + {this.props.children[0]} + {this.props.children[1]} +
    + ); + } + } + + render () { + let classMap = (this.props.style && styles.getClassesMap(this.props.style)) || {}; + + let props = { + tag: 'div', + element: this.props.element, + settings: this.constructor.settings, + className: cx(classes.holder, classMap.holder) + }; + + return ( + +
    + {this.renderChildren()} +
    +
    + ); + } +} + +Button.propTypes = { +}; + +Button.contextTypes = { + editing: React.PropTypes.bool.isRequired, + elementContentChange: React.PropTypes.func.isRequired, + selected: React.PropTypes.any +}; + +Button.defaultProps = { + layout: 'text', + arrange: 'side' +}; + +Button.defaultChildren = [ + { + tag: 'TextBox', + children: 'Button text', + subComponent: true + } +]; + +styles.registerStyle(style); +Button.propsSchema = propsSchema; +Button.settings = settings; diff --git a/lib/components/elements/button/props-schema.js b/lib/components/elements/button/props-schema.js new file mode 100644 index 000000000..c54a4c8a5 --- /dev/null +++ b/lib/components/elements/button/props-schema.js @@ -0,0 +1,35 @@ +export default [ + { + label: 'Layout', + type: 'Select', + id: 'layout', + props: { + labels: ['Text', 'Icon - Text', 'Text - Icon', 'Icon'], + values: ['text', 'icontext', 'texticon', 'icon'] + }, + unlocks: { + 'icontext': [ + { + label: 'Arrange', + type: 'Select', + id: 'arrange', + props: { + labels: ['Side by side', 'Blocks'], + values: ['side', 'blocks'] + } + } + ], + 'texticon': [ + { + label: 'Arrange', + type: 'Select', + id: 'arrange', + props: { + labels: ['Side by side', 'Blocks'], + values: ['side', 'blocks'] + } + } + ] + } + } +]; diff --git a/lib/components/elements/button/settings.js b/lib/components/elements/button/settings.js new file mode 100644 index 000000000..0b1f81f67 --- /dev/null +++ b/lib/components/elements/button/settings.js @@ -0,0 +1,10 @@ +export default { + icon: { + class: 'material-icons', + content: 'link' + }, + style: 'button', + category: 'content', + drop: false, + drag: {} +}; diff --git a/lib/components/elements/button/style.js b/lib/components/elements/button/style.js new file mode 100644 index 000000000..56211fbf2 --- /dev/null +++ b/lib/components/elements/button/style.js @@ -0,0 +1,241 @@ +import {Types} from '../../../types'; +import Colors from '../../../colors'; +import Utils from '../../../utils'; + +export default { + type: 'button', + options: [ + { + label: 'Size', + type: Types.Select, + id: 'size', + props: { + labels: ['Full Width', 'Fit Content', 'Max Width (px)', 'Strict (px)'], + values: ['full', 'fit', 'max', 'strict'] + }, + unlocks: { + fit : [ + { + label: 'Horizontal alignment', + type: Types.Select, + id: 'alignment', + props: { + labels: ['Left', 'Center', 'Right'], + values: ['left', 'center', 'right'] + } + } + ], + max: [ + { + label: 'Max Width', + type: Types.Pixels, + id: 'maxWidth' + }, + { + label: 'Horizontal alignment', + type: Types.Select, + id: 'alignment', + props: { + labels: ['Left', 'Center', 'Right'], + values: ['left', 'center', 'right'] + } + } + ], + strict: [ + { + label: 'Width', + type: Types.Pixels, + id: 'width' + }, + { + label: 'Height', + type: Types.Pixels, + id: 'height' + }, + { + label: 'Horizontal alignment', + type: Types.Select, + id: 'alignment', + props: { + labels: ['Left', 'Center', 'Right'], + values: ['left', 'center', 'right'] + } + } + ] + } + }, + { + label: 'Color (overlaps texts color)', + type: 'Optional', + id: 'useColor', + unlocks: [ + { + type: Types.Color, + id: 'color' + } + ] + }, + { + label: 'Color On Over', + type: 'Optional', + id: 'useColorHover', + unlocks: [ + { + type: Types.Color, + id: 'colorHover' + } + ] + }, + { + label: 'Use Background', + type: 'Optional', + id: 'useBackground', + unlocks: [ + { + label: 'Background Color', + type: Types.Color, + id: 'backgroundColor' + }, + { + label: 'Background Color on over', + type: Types.Color, + id: 'backgroundColorOver' + } + ] + }, + { + label: 'Border', + type: 'Optional', + id: 'useBorder', + unlocks: [ + { + type: Types.Border, + id: 'border' + }, + { + label: 'Border Color on over', + type: Types.Color, + id: 'borderColorOver' + } + ] + }, + { + label: 'Rounded Corners', + type: 'Optional', + id: 'useCorners', + unlocks: [ + { + type: Types.Corners, + id: 'corners' + } + ] + }, + { + label: 'Padding', + type: 'Optional', + id: 'usePadding', + unlocks: [ + { + type: Types.Padding, + id: 'padding' + } + ] + }, + { + label: 'Animation on hover', + type: 'Optional', + id: 'useAnimation', + unlocks: [ + { + type: Types.Number, + id: 'animationDuration', + props: { + label: 'ms' + } + } + ] + } + ], + defaults: { + size: 'fit', + maxWidth: 200, + width: 70, + height: 70, + alignment: 'center', + useColor: false, + color: { + value: '#ffffff', + opacity: 100 + }, + useColorHover: false, + colorHover: { + value: '#ffffff', + opacity: 100 + }, + useBackground: false, + backgroundColor: { + value: '#ffffff', + opacity: 100 + }, + backgroundColorHover: { + value: '#ffffff', + opacity: 100 + }, + useBorder: false, + border: false, + borderColorOver: { + value: '#ffffff', + opacity: 100 + }, + useCorners: false, + corners: '0px', + usePadding: false, + padding: '0px', + useAnimation: false, + animationDuration: 500 + }, + rules: (props) => { + let rules = { + button: { + backgroundColor: props.useBackground && Colors.getColorString(props.backgroundColor), + borderRadius: props.useCorners && props.corners, + padding: props.usePadding && props.padding, + '*': { + color: props.useColor && Colors.getColorString(props.color) + }, + ':hover': { + '*': { + color: props.useColorHover && Colors.getColorString(props.colorHover) + }, + backgroundColor: props.useBackground && Colors.getColorString(props.backgroundColorHover), + } + }, + holder: {} + }; + + if (props.size === 'strict') { + rules.button.width = props.width; + rules.button.height = props.height; + } else if (props.size === 'fit') { + rules.button.display = 'inline-block'; + } else if (props.size === 'max') { + rules.button.maxWidth = props.maxWidth; + } + + if (props.size !== 'full') { + rules.holder.textAlign = props.alignment; + rules.button.display = 'inline-block'; + } + + if (props.useAnimation) { + rules.button.transition = 'all '+props.animationDuration+'ms cubic-bezier(0.190, 1.000, 0.220, 1.000)'; + } + + if (props.useBorder) { + Utils.applyBorders(rules.button, props.border); + rules.button[':hover'].borderColor = Colors.getColorString(props.borderColorOver); + } + + return rules; + } +}; diff --git a/lib/components/elements/column.jsx b/lib/components/elements/column.jsx new file mode 100644 index 000000000..112ccec65 --- /dev/null +++ b/lib/components/elements/column.jsx @@ -0,0 +1,83 @@ +import React from 'react'; +import Component from '../component'; +import Element from '../element'; +import {Types} from '../../types'; + +export default class Column extends Component { + render () { + const layout = this.props.layout || { + width: 'auto' + }; + + var style = { + display: layout.width === 'block' ? 'block' : 'table-cell', + verticalAlign: this.props.vertical + }; + + if (this.props.left || this.props.right) { + style.padding = '0px '+this.props.right+'px 0px '+this.props.left+'px'; + } + if (this.props.bottom) { + style.marginBottom = this.props.bottom; + } + + var contentStyle = { + padding: this.props.padding + }; + + if (layout.width !== 'block') { + style.width = layout.widthPerc+'%'; + } + + return ( + +
    + {this.renderContent()} +
    +
    + ); + } +} + +Column.settings = { + icon: { + class: 'material-icons', + content: 'view_carousel' + }, + category: 'structure', + drop: { + rejects: 'Section', + customDropArea: true + }, + drag: { + droppableOn: 'Columns' + } +}; + +Column.propTypes = { + padding: React.PropTypes.string.isRequired, + vertical: React.PropTypes.string.isRequired, + columnsDisplay: React.PropTypes.string.isRequired +}; + +Column.defaultProps = { + padding: '15px', + vertical: 'top' +}; + +Column.propsSchema = [ + { + label: 'Padding', + type: Types.String, + id: 'padding' + }, + { + label: 'Content vertical align', + type: Types.Select, + id: 'vertical', + props: { + labels: ['Top', 'Center', 'Bottom'], + values: ['top', 'middle', 'bottom'] + } + } +]; diff --git a/lib/components/elements/columns/index.jsx b/lib/components/elements/columns/index.jsx new file mode 100644 index 000000000..9e1cb59b4 --- /dev/null +++ b/lib/components/elements/columns/index.jsx @@ -0,0 +1,132 @@ +import React from 'react'; +import Component from '../../component'; +import Element from '../../element'; +import Utils from '../../../utils'; +import {Droppable} from '../../drag'; + +import jss from '../../../react-jss'; +import settings from './settings'; +import propsSchema from './props-schema'; + +export default class Columns extends Component { + + renderBlock (child, layout, bottom) { + return React.cloneElement(child, { + layout, + bottom + }); + } + + renderColumn (child, layout, left, right) { + return React.cloneElement(child, { + layout, + left, + right + }); + } + + renderChildren () { + var children = [], i, numChildren = this.props.children.length; + const layout = Utils.parseColumnsDisplay(this.props[this.context.display], numChildren, this.context.display !== 'desktop'); + + const spaceThird = Math.round(this.props.spacing / 3 * 100) / 100; + const spaceSides = spaceThird * 2; + + var dropInfo = { + id: this.props.element.id + }; + + if (numChildren > 0) { + for (i = 0; i < numChildren; i++) { + if (layout[i].width === 'block') { + children.push(this.renderBlock(this.props.children[i], layout[i], i !== numChildren - 1 ? this.props.spacing : 0)); + } else { + var columns = []; + for (i; i < numChildren; i++) { + if (layout[i].width !== 'block' && !(columns.length > 0 && layout[i].break)) { + let isLastColumn = (columns.length !== 0 && (i === numChildren - 1 || (layout[i + 1].width === 'block' || layout[i + 1].break))); + let left = columns.length === 0 ? 0 : (isLastColumn ? spaceSides : spaceThird); + let right = columns.length === 0 ? spaceSides : (isLastColumn ? 0 : spaceThird); + + columns.push(this.renderColumn(this.props.children[i], layout[i], left, right)); + } else { + i--; + break; + } + } + + if (this.context.editing && this.context.display === 'desktop') { + return ( + + {columns} + + ); + } else { + let style = {}; + + if (i < numChildren - 1) { + style.paddingBottom = this.props.spacingRows; + } + + children.push( +
    + {columns} +
    + ); + } + } + } + } else if (this.context.editing) { + return ( + + ); + } + + + return children; + } + + render () { + return ( + + {this.renderChildren()} + + ); + } +} + +var classes = jss.createRules({ + row: { + display: 'table', + tableLayout: 'fixed', + width: '100%' + } +}); + +Columns.contextTypes = { + editing: React.PropTypes.bool.isRequired, + display: React.PropTypes.string.isRequired +}; + +Columns.propTypes = { + spacing: React.PropTypes.number.isRequired, + spacingRows: React.PropTypes.number.isRequired, + desktop: React.PropTypes.array.isRequired, + tablet: React.PropTypes.array.isRequired, + mobile: React.PropTypes.array.isRequired +}; + +Columns.defaultProps = { + spacing: 10, + spacingRows: 10, + desktop: [], + tablet: [], + mobile: [] +}; + +Columns.defaultChildren = [ + {tag: 'Column'}, {tag: 'Column'} +]; + +Columns.settings = settings; +Columns.propsSchema = propsSchema; diff --git a/lib/components/elements/columns/props-schema.js b/lib/components/elements/columns/props-schema.js new file mode 100644 index 000000000..7cd5d7e98 --- /dev/null +++ b/lib/components/elements/columns/props-schema.js @@ -0,0 +1,42 @@ +import {Types} from '../../../types'; + +export default [ + { + id: 'add-button', + label: false, + type: Types.Button, + props: { + label: 'Add column', + action: 'addElement', + actionProps: 'Column' + } + }, + { + label: 'Space between columns', + type: Types.Pixels, + id: 'spacing' + }, + { + label: 'Space between rows (not used on desktop)', + type: Types.Pixels, + id: 'spacingRows' + }, + { + label: 'Desktop display', + type: 'Columns', + id: 'desktop', + props: { + multiRows: false + } + }, + { + label: 'Tablet display', + type: 'Columns', + id: 'tablet' + }, + { + label: 'Mobile display', + type: 'Columns', + id: 'mobile' + } +]; diff --git a/lib/components/elements/columns/settings.js b/lib/components/elements/columns/settings.js new file mode 100644 index 000000000..231669db6 --- /dev/null +++ b/lib/components/elements/columns/settings.js @@ -0,0 +1,14 @@ +export default { + icon: { + class: 'material-icons', + content: 'view_column' + }, + category: 'structure', + drop: { + orientation: 'horizontal', + selectionChildren: 'column', + accepts: 'Column', + customDropArea: true + }, + drag: {} +}; diff --git a/lib/components/elements/container/index.jsx b/lib/components/elements/container/index.jsx new file mode 100644 index 000000000..b084c42f4 --- /dev/null +++ b/lib/components/elements/container/index.jsx @@ -0,0 +1,41 @@ +import React from 'react'; +import Component from '../../component'; +import Element from '../../element'; +import styles from '../../../styles'; + +import settings from './settings'; +import style from './style'; +import propsSchema from './props-schema'; + +export default class Container extends Component { + render () { + let classMap = this.props.style && styles.getClassesMap(this.props.style); + let className = classMap && classMap.container || ''; + let classNameHolder = classMap && classMap.holder || ''; + + let props = { + tag: 'div', + style: { + position: 'relative' + }, + className, + settings: this.constructor.settings, + element: this.props.element + }; + + return ( +
    + + {this.props.children} + +
    + ); + } +} + +Container.propTypes = {}; +Container.defaultProps = {}; + +styles.registerStyle(style); +Container.propsSchema = propsSchema; +Container.settings = settings; diff --git a/lib/components/elements/container/props-schema.js b/lib/components/elements/container/props-schema.js new file mode 100644 index 000000000..d6d1738de --- /dev/null +++ b/lib/components/elements/container/props-schema.js @@ -0,0 +1 @@ +export default []; diff --git a/lib/components/elements/container/settings.js b/lib/components/elements/container/settings.js new file mode 100644 index 000000000..524759fb1 --- /dev/null +++ b/lib/components/elements/container/settings.js @@ -0,0 +1,12 @@ +export default { + icon: { + class: 'material-icons', + content: 'view_array' + }, + category: 'structure', + style: 'container', + drop: { + rejects: 'Section' + }, + drag: {} +}; diff --git a/lib/components/elements/container/style.js b/lib/components/elements/container/style.js new file mode 100644 index 000000000..86ddf4101 --- /dev/null +++ b/lib/components/elements/container/style.js @@ -0,0 +1,129 @@ +import {Types} from '../../../types'; +import Colors from '../../../colors'; +import Utils from '../../../utils'; + +export default { + type: 'container', + options: [ + { + label: 'Background Color', + type: Types.Select, + id: 'backgroundColor', + props: { + labels: ['Transparent', 'Color'], + values: ['transparent', 'color'] + }, + unlocks: { + color: [ + { + label: 'Background color', + type: Types.Color, + id: 'color' + } + ] + } + }, + { + label: 'Width', + type: Types.Select, + id: 'width', + props: { + labels: ['Full Width', 'Max Width'], + values: ['full', 'max'] + }, + unlocks: { + max: [ + { + label: 'Maximum Width', + type: Types.Pixels, + id: 'widthPx', + props: { + min: 0, + max: false + } + }, + { + label: 'Content horizontal alignment', + type: Types.Select, + id: 'contentHorizontal', + props: { + labels: ['Left', 'Center', 'Right'], + values: ['left', 'center', 'right'] + } + } + ] + } + }, + { + label: 'Padding', + type: Types.Padding, + id: 'padding' + }, + { + label: 'Rounded Corners', + type: Types.Corners, + id: 'corners' + }, + { + label: 'Border', + type: Types.Border, + id: 'border' + } + ], + defaults: { + backgroundColor: 'transparent', + color: { + value: '#ffffff', + opacity: 100 + }, + width: 'max', + widthPx: 100, + contentHorizontal: 'center', + padding: '20px', + corners: '0px' + }, + rules: (props) => { + var rule = {}; + var holderRule = {}; + + if (props.backgroundColor === 'color') { + rule.backgroundColor = Colors.getColorString(props.color); + } + + if (props.width === 'max') { + rule.maxWidth = props.widthPx; + rule.width = '100%'; + rule.display = 'inline-block'; + + holderRule.textAlign = props.contentHorizontal; + } + + rule.padding = props.padding; + rule.borderRadius = props.corners; + Utils.applyBorders(rule, props.border); + + return { + container: rule, + holder: holderRule + }; + }, + getIdentifierLabel: (props) => { + var str = ''; + + if (props.width === 'max') { + str += props.widthPx+'px'; + } else { + str += 'Full'; + } + + str += ' | '; + + if (props.backgroundColor === 'color') { + str += Colors.getColorString(props.color); + } else { + str += 'transparent'; + } + + return str; + } +}; diff --git a/lib/components/elements/counter/index.jsx b/lib/components/elements/counter/index.jsx new file mode 100644 index 000000000..5605c6d1c --- /dev/null +++ b/lib/components/elements/counter/index.jsx @@ -0,0 +1,70 @@ +import React from 'react'; +import Component from '../../component'; +import Element from '../../element'; +import ReactCounter from 'react-counter'; +import styles from '../../../styles'; +import cx from 'classnames'; + +import settings from './settings'; +import propsSchema from './props-schema'; + +export default class Counter extends Component { + + getInitialState () { + return { + animate: false + }; + } + + onEnterScreen () { + this.setState({ + animate: true + }); + } + + renderCounter () { + if (this.state.animate) { + return ( + + ); + } else { + return {this.props.begin}; + } + } + + render () { + var classMap = (this.props.style && styles.getClassesMap(this.props.style)) || {}; + + var props = { + tag: 'div', + element: this.props.element, + settings: this.constructor.settings, + onEnterScreen: this.onEnterScreen.bind(this), + className: cx(classMap.text), + style: { + textAlign: this.props.align + } + }; + + return ( + + {this.renderCounter()} + + ); + } +} + +Counter.propTypes = { + icon: React.PropTypes.string.isRequired, + style: React.PropTypes.any.isRequired +}; + +Counter.defaultProps = { + begin: 0, + end: 100, + duration: 2000, + align: 'center' +}; + +Counter.propsSchema = propsSchema; +Counter.settings = settings; diff --git a/lib/components/elements/counter/props-schema.js b/lib/components/elements/counter/props-schema.js new file mode 100644 index 000000000..75732cb53 --- /dev/null +++ b/lib/components/elements/counter/props-schema.js @@ -0,0 +1,28 @@ +import {Types} from '../../../types'; + +export default [ + { + label: 'Begin', + type: Types.Number, + id: 'begin' + }, + { + label: 'End', + type: Types.Number, + id: 'end' + }, + { + label: 'Duration', + type: Types.Number, + id: 'duration' + }, + { + label: 'Alignment', + type: Types.Select, + id: 'align', + props: { + labels: ['Left', 'Center', 'Right'], + values: ['left', 'center', 'right'] + } + } +]; diff --git a/lib/components/elements/counter/settings.js b/lib/components/elements/counter/settings.js new file mode 100644 index 000000000..36e2f743d --- /dev/null +++ b/lib/components/elements/counter/settings.js @@ -0,0 +1,10 @@ +export default { + icon: { + class: 'fa fa-sort-numeric-asc', + content: '' + }, + category: 'content', + style: 'text', + drop: false, + drag: {} +}; diff --git a/lib/components/elements/gap/index.jsx b/lib/components/elements/gap/index.jsx new file mode 100644 index 000000000..9db2e0c61 --- /dev/null +++ b/lib/components/elements/gap/index.jsx @@ -0,0 +1,29 @@ +import React from 'react'; +import Component from '../../component'; +import Element from '../../element'; + +import settings from './settings'; +import propsSchema from './props-schema'; + +export default class Gap extends Component { + render () { + var style = { + height: this.props.amount + }; + + return ( + + ); + } +} + +Gap.propTypes = { + amount: React.PropTypes.number.isRequired +}; + +Gap.defaultProps = { + amount: 30 +}; + +Gap.propsSchema = propsSchema; +Gap.settings = settings; diff --git a/lib/components/elements/gap/props-schema.js b/lib/components/elements/gap/props-schema.js new file mode 100644 index 000000000..96fc8ba15 --- /dev/null +++ b/lib/components/elements/gap/props-schema.js @@ -0,0 +1,9 @@ +import {Types} from '../../../types'; + +export default [ + { + label: 'Size', + type: Types.Pixels, + id: 'amount' + } +]; diff --git a/lib/components/elements/gap/settings.js b/lib/components/elements/gap/settings.js new file mode 100644 index 000000000..f99f08b5c --- /dev/null +++ b/lib/components/elements/gap/settings.js @@ -0,0 +1,9 @@ +export default { + icon: { + class: 'material-icons', + content: 'vertical_align_bottom' + }, + category: 'structure', + drop: false, + drag: {} +}; diff --git a/lib/components/elements/google-maps/index.jsx b/lib/components/elements/google-maps/index.jsx new file mode 100644 index 000000000..24d625b20 --- /dev/null +++ b/lib/components/elements/google-maps/index.jsx @@ -0,0 +1,155 @@ +import React from 'react'; +import Component from '../../component'; +import Element from '../../element'; +import {GoogleMaps, Marker} from 'react-google-maps'; +import Utils from '../../../utils'; + +import settings from './settings'; +import propsSchema from './props-schema'; + +export default class GoogleMapsElem extends Component { + + getInitialState () { + return { + ready: this.loadAPI() + }; + } + + shouldComponentUpdate (nextProps, nextState) { + return ( + this.context.editing && this.props.selected || + nextState.ready !== this.state.ready + ); + } + + componentDidUpdate (prevProps) { + if (this.context.editing && this.state.ready && prevProps.height !== this.props.height) { + if (this.refs.map && this.refs.map.state && this.refs.map.state.instance) { + window.google.maps.event.trigger(this.refs.map.state.instance, 'resize'); + } + } + } + + loadAPI () { + if (typeof document !== 'undefined') { + if (!Utils.hasClass(document.body, 'googleMapsInitiated') && !Utils.hasClass(document.body, 'googleMapsLoading')) { + Utils.addClass(document.body, 'googleMapsLoading'); + + window.googleMapsInitiated = function () { + Utils.removeClass(document.body, 'googleMapsLoading'); + Utils.addClass(document.body, 'googleMapsInitiated'); + /* jshint ignore:start */ + window.dispatchEvent(new Event('googleMapsInitiated')); + /* jshint ignore:end */ + }; + + var script = document.createElement('script'); + script.type = 'text/javascript'; + script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&callback=googleMapsInitiated'; + document.body.appendChild(script); + + window.addEventListener('googleMapsInitiated', this.onReady.bind(this)); + + return false; + } else if (!Utils.hasClass(document.body, 'googleMapsInitiated')) { + window.addEventListener('googleMapsInitiated', this.onReady.bind(this)); + return false; + } else { + return true; + } + } + } + + onReady () { + this.setState({ + ready: true + }); + } + + renderMarker () { + if (this.props.useMarker) { + var position = { + lat: parseFloat(this.props.lat, 10), + lng: parseFloat(this.props.lng, 10) + }; + return ( + + ); + } + } + + renderMap () { + if (this.state.ready) { + var gmap = ( + {this.renderMarker()} + ); + + if (this.context.editing) { + return ( +
    + {gmap} +
    +
    + ); + } else { + return gmap; + } + } + } + + render () { + return ( + + {this.renderMap()} + + ); + } +} + +GoogleMapsElem.contextTypes = { + editing: React.PropTypes.bool.isRequired +}; + +GoogleMapsElem.propTypes = { + zoom: React.PropTypes.number.isRequired, + lat: React.PropTypes.string.isRequired, + lng: React.PropTypes.string.isRequired, + height: React.PropTypes.number.isRequired, + scrollwheel: React.PropTypes.bool.isRequired, + panControl: React.PropTypes.bool.isRequired, + zoomControls: React.PropTypes.bool.isRequired, + mapTypeControl: React.PropTypes.bool.isRequired, + streetViewControl: React.PropTypes.bool.isRequired, + useMarker: React.PropTypes.bool.isRequired +}; + +GoogleMapsElem.defaultProps = { + zoom: 15, + lat: '41.1761671', + lng: '-8.601692', + height: 250, + scrollwheel: false, + panControl: false, + zoomControls: true, + mapTypeControl: false, + streetViewControl: true, + useMarker: true +}; + +GoogleMapsElem.propsSchema = propsSchema; +GoogleMapsElem.settings = settings; diff --git a/lib/components/elements/google-maps/props-schema.js b/lib/components/elements/google-maps/props-schema.js new file mode 100644 index 000000000..a298003b0 --- /dev/null +++ b/lib/components/elements/google-maps/props-schema.js @@ -0,0 +1,60 @@ +import {Types} from '../../../types'; +import React from 'react'; + +export default [ + { + label: 'Zoom', + type: Types.Number, + id: 'zoom', + props: { + min: 0, + max: 21, + label: + } + }, + { + label: 'Latitude', + type: Types.String, + id: 'lat' + }, + { + label: 'Longitude', + type: Types.String, + id: 'lng' + }, + { + label: 'Height', + type: Types.Pixels, + id: 'height' + }, + { + label: 'Use scrollwheel', + type: Types.Boolean, + id: 'scrollwheel' + }, + { + label: 'Pan Control', + type: Types.Boolean, + id: 'panControl' + }, + { + label: 'Zoom controls', + type: Types.Boolean, + id: 'zoomControls' + }, + { + label: 'Map Type Controls', + type: Types.Boolean, + id: 'mapTypeControl' + }, + { + label: 'Streetview Control', + type: Types.Boolean, + id: 'streetViewControl' + }, + { + label: 'Use marker', + type: Types.Boolean, + id: 'useMarker' + } +]; diff --git a/lib/components/elements/google-maps/settings.js b/lib/components/elements/google-maps/settings.js new file mode 100644 index 000000000..3be50f73d --- /dev/null +++ b/lib/components/elements/google-maps/settings.js @@ -0,0 +1,9 @@ +export default { + icon: { + class: 'fa fa-google', + content: '' + }, + category: 'media', + drop: false, + drag: {} +}; diff --git a/lib/components/elements/icon/classes.js b/lib/components/elements/icon/classes.js new file mode 100644 index 000000000..74ce45458 --- /dev/null +++ b/lib/components/elements/icon/classes.js @@ -0,0 +1,8 @@ +import jss from '../../../react-jss'; + +export default jss.createRules({ + holder: { + display: 'inline-block', + textAlign: 'center' + } +}); diff --git a/lib/components/elements/icon/index.jsx b/lib/components/elements/icon/index.jsx new file mode 100644 index 000000000..57e5597f7 --- /dev/null +++ b/lib/components/elements/icon/index.jsx @@ -0,0 +1,46 @@ +import React from 'react'; +import Component from '../../component'; +import Element from '../../element'; +import styles from '../../../styles'; +import cx from 'classnames'; + +import settings from './settings'; +import style from './style'; +import propsSchema from './props-schema'; +import classes from './classes'; + +export default class Icon extends Component { + render () { + let classMap = (this.props.style && styles.getClassesMap(this.props.style)) || {}; + var props = { + tag: 'div', + element: this.props.element, + settings: this.constructor.settings, + style: { + textAlign: this.props.align + } + }; + + return ( + +
    + +
    +
    + ); + } +} + +Icon.propTypes = { + icon: React.PropTypes.string.isRequired, + style: React.PropTypes.any.isRequired +}; + +Icon.defaultProps = { + icon: 'fa fa-beer', + align: 'center' +}; + +styles.registerStyle(style); +Icon.propsSchema = propsSchema; +Icon.settings = settings; diff --git a/lib/components/elements/icon/props-schema.js b/lib/components/elements/icon/props-schema.js new file mode 100644 index 000000000..d1599044a --- /dev/null +++ b/lib/components/elements/icon/props-schema.js @@ -0,0 +1,18 @@ +import {Types} from '../../../types'; + +export default [ + { + label: 'Icon', + type: Types.Icon, + id: 'icon' + }, + { + label: 'Alignment', + type: Types.Select, + id: 'align', + props: { + labels: ['Left', 'Center', 'Right'], + values: ['left', 'center', 'right'] + } + } +]; diff --git a/lib/components/elements/icon/settings.js b/lib/components/elements/icon/settings.js new file mode 100644 index 000000000..f90d11b20 --- /dev/null +++ b/lib/components/elements/icon/settings.js @@ -0,0 +1,10 @@ +export default { + icon: { + class: 'fa fa-flag', + content: '' + }, + style: 'icon', + category: 'content', + drop: false, + drag: {} +}; diff --git a/lib/components/elements/icon/style.js b/lib/components/elements/icon/style.js new file mode 100644 index 000000000..02d81048e --- /dev/null +++ b/lib/components/elements/icon/style.js @@ -0,0 +1,92 @@ +import {Types} from '../../../types'; +import Colors from '../../../colors'; + +export default { + type: 'icon', + options: [ + { + label: 'Color', + type: Types.Color, + id: 'color' + }, + { + label: 'Font size', + type: Types.Pixels, + id: 'size' + }, + { + label: 'Use Background', + type: Types.Boolean, + id: 'background', + unlocks: { + true: [ + { + label: 'Width', + type: Types.Pixels, + id: 'width' + }, + { + label: 'Height', + type: Types.Pixels, + id: 'height' + }, + { + label: 'Background Color', + type: Types.Color, + id: 'backgroundColor' + }, + { + label: 'Rounded Corners', + type: Types.Corners, + id: 'corners' + } + ] + } + } + ], + defaults: { + color: { + value: '#ffffff', + opacity: 100 + }, + size: 16, + background: false, + width: 70, + height: 70, + backgroundColor: { + value: '#000000', + opacity: 100 + }, + corners: '0px' + }, + rules: (props) => { + let rules = { + icon: {} + }; + + rules.icon.fontSize = props.size; + rules.icon.color = Colors.getColorString(props.color); + + if (props.background) { + rules.holder = {}; + + rules.holder.width = props.width; + rules.holder.height = props.height; + rules.holder.backgroundColor = Colors.getColorString(props.backgroundColor); + rules.holder.borderRadius = props.corners; + + rules.icon.lineHeight = props.height + 'px'; + } + + return rules; + }, + getIdentifierLabel: (props) => { + var str = ''; + + str += props.size+'px'; + str += ' | '; + str += Colors.getColorString(props.color); + + return str; + } +}; diff --git a/lib/components/elements/image/index.jsx b/lib/components/elements/image/index.jsx new file mode 100644 index 000000000..5df980829 --- /dev/null +++ b/lib/components/elements/image/index.jsx @@ -0,0 +1,82 @@ +import React from 'react'; +import Component from '../../component'; +import Element from '../../element'; +import MediaImage from '../../image'; +import Utils from '../../../utils'; +import Colors from '../../../colors'; + +import settings from './settings'; +import propsSchema from './props-schema'; + +export default class Image extends Component { + getInitialState () { + return { + mounted: false + }; + } + + componentDidMount () { + var dom = React.findDOMNode(this); + var rect = dom.getBoundingClientRect(); + + var width = Math.round(rect.right-rect.left); + + this.setState({ + mounted: true, + width + }); + } + + render () { + var style = { + backgroundColor: Colors.getColorString(this.props.color) + }; + var imageStyle = {}; + + if (this.props.height === 'strict') { + style.height = this.props.height_px; + style.overflow = 'hidden'; + + Utils.translate(imageStyle, 0, (-this.props.vertical)+'%'); + imageStyle.top = this.props.height_px * (this.props.vertical / 100); + imageStyle.position = 'relative'; + } + + if (this.props.width === 'max') { + imageStyle.maxWidth = this.props.width_px; + style.textAlign = this.props.horizontal; + } else { + imageStyle.minWidth = '100%'; + } + + return ( + + {this.state.mounted ? : null} + + ); + } +} + +Image.propTypes = { + color: React.PropTypes.string.isRequired, + image: React.PropTypes.string.isRequired, + height: React.PropTypes.string.isRequired, + height_px: React.PropTypes.number, + vertical: React.PropTypes.number +}; + +Image.defaultProps = { + color: { + value: '#ffffff', + opacity: 0 + }, + height: 'auto', + height_px: 200, + vertical: 50, + width: 'full', + width_px: 300, + horizontal: 'center' +}; + +Image.propsSchema = propsSchema; +Image.settings = settings; diff --git a/lib/components/elements/image/props-schema.js b/lib/components/elements/image/props-schema.js new file mode 100644 index 000000000..de1e5563b --- /dev/null +++ b/lib/components/elements/image/props-schema.js @@ -0,0 +1,64 @@ +import {Types} from '../../../types'; + +export default [ + { + label: 'Background color', + type: Types.Color, + id: 'color' + }, + { + label: 'Background Image', + type: Types.Image, + id: 'image' + }, + { + label: 'Height', + type: Types.Select, + id: 'height', + props: { + labels: ['Auto', 'Strict'], + values: ['auto', 'strict'] + }, + unlocks: { + strict: [ + { + label: 'Pixels', + type: Types.Pixels, + id: 'height_px' + }, + { + label: 'Vertical position', + type: Types.Percentage, + id: 'vertical' + } + ] + } + }, + { + label: 'Width', + type: Types.Select, + id: 'width', + props: { + labels: ['Full width', 'Max. width'], + values: ['full', 'max'] + }, + unlocks: { + max: [ + { + label: 'Pixels', + type: Types.Pixels, + id: 'width_px' + }, + { + label: 'Horizontal alignment', + type: Types.Select, + id: 'horizontal', + props: { + labels: ['Left', 'Center', 'Right'], + values: ['left', 'center', 'right'] + } + } + ] + } + } +]; diff --git a/lib/components/elements/image/settings.js b/lib/components/elements/image/settings.js new file mode 100644 index 000000000..21fe41787 --- /dev/null +++ b/lib/components/elements/image/settings.js @@ -0,0 +1,9 @@ +export default { + icon: { + class: 'fa fa-image', + content: '' + }, + category: 'media', + drop: false, + drag: {} +}; diff --git a/lib/components/elements/index.js b/lib/components/elements/index.js new file mode 100644 index 000000000..c1d6e2d80 --- /dev/null +++ b/lib/components/elements/index.js @@ -0,0 +1,33 @@ +import Button from './button'; +import Section from './section'; +import Container from './container'; +import Columns from './columns'; +import Column from './column'; +import TextBox from './text-box'; +import Image from './image'; +import Video from './video'; +import Gap from './gap'; +import LineDivider from './line-divider'; +import GoogleMaps from './google-maps'; +import Icon from './icon'; +import Counter from './counter'; +import Schema from './schema'; +import MusicPlayer from './music-player'; + +export default { + Button, + Section, + Container, + Columns, + Column, + TextBox, + Image, + Video, + Gap, + LineDivider, + GoogleMaps, + Icon, + Counter, + Schema, + MusicPlayer +}; diff --git a/lib/components/elements/line-divider/classes.js b/lib/components/elements/line-divider/classes.js new file mode 100644 index 000000000..6a44bfd37 --- /dev/null +++ b/lib/components/elements/line-divider/classes.js @@ -0,0 +1,10 @@ +import jss from '../../../react-jss'; + +export default jss.createRules({ + holder: { + height: '1px' + }, + line: { + borderBottom: '1px solid #000000' + } +}); diff --git a/lib/components/elements/line-divider/index.jsx b/lib/components/elements/line-divider/index.jsx new file mode 100644 index 000000000..7cce51109 --- /dev/null +++ b/lib/components/elements/line-divider/index.jsx @@ -0,0 +1,36 @@ +import React from 'react'; +import Component from '../../component'; +import Element from '../../element'; +import styles from '../../../styles'; +import cx from 'classnames'; + +import settings from './settings'; +import style from './style'; +import classes from './classes'; +import propsSchema from './props-schema'; + +export default class LineDivider extends Component { + render () { + let classMap = (this.props.style && styles.getClassesMap(this.props.style)) || {}; + let style = { + padding: this.props.padding + }; + + return ( + +
    +
    + ); + } +} + +LineDivider.propTypes = { + padding: React.PropTypes.string.isRequired +}; +LineDivider.defaultProps = { + padding: '0px' +}; + +styles.registerStyle(style); +LineDivider.propsSchema = propsSchema; +LineDivider.settings = settings; diff --git a/lib/components/elements/line-divider/props-schema.js b/lib/components/elements/line-divider/props-schema.js new file mode 100644 index 000000000..60fc62175 --- /dev/null +++ b/lib/components/elements/line-divider/props-schema.js @@ -0,0 +1,9 @@ +import {Types} from '../../../types'; + +export default [ + { + label: 'Padding', + type: Types.Padding, + id: 'padding' + } +]; diff --git a/lib/components/elements/line-divider/settings.js b/lib/components/elements/line-divider/settings.js new file mode 100644 index 000000000..ea9877b30 --- /dev/null +++ b/lib/components/elements/line-divider/settings.js @@ -0,0 +1,10 @@ +export default { + icon: { + class: 'fa fa-minus', + content: '' + }, + category: 'structure', + style: 'lineDivider', + drop: false, + drag: {} +}; diff --git a/lib/components/elements/line-divider/style.js b/lib/components/elements/line-divider/style.js new file mode 100644 index 000000000..356f0a5ee --- /dev/null +++ b/lib/components/elements/line-divider/style.js @@ -0,0 +1,109 @@ +import React from 'react'; +import {Types} from '../../../types'; +import Colors from '../../../colors'; + +export default { + type: 'lineDivider', + options: [ + { + label: 'Line Height', + type: Types.Pixels, + id: 'size' + }, + { + label: 'Style', + type: Types.String, + id: 'style' + }, + { + label: 'Color', + type: Types.Color, + id: 'color' + }, + { + label: 'Max Width', + type: Types.Select, + id: 'width', + props: { + labels: ['Full width', 'Strict'], + values: ['full', 'strict'] + }, + unlocks: { + strict: [ + { + label: 'Max Width', + type: Types.Pixels, + id: 'maxWidth' + }, + { + label: 'Align', + type: Types.Select, + id: 'align', + props: { + labels: ['Left', 'Center', 'Right'], + values: ['left', 'center', 'right'] + } + } + ] + } + } + ], + defaults: { + size: 1, + style: 'solid', + color: { + value: '#000000', + opacity: 100 + }, + width: 'full', + maxWidth: 100, + align: 'center' + }, + rules: (props) => { + let rules = { + line: {}, + holder: {} + }; + + rules.line.borderBottom = props.size+'px '+props.style+' '+Colors.getColorString(props.color); + rules.holder.height = props.size; + + if (props.width === 'strict') { + rules.line.display = 'inline-block'; + rules.line.width = props.maxWidth; + rules.line.maxWidth = '100%'; + rules.line.verticalAlign = 'top'; + rules.holder.textAlign = props.align; + } + + return rules; + }, + getIdentifierLabel: (props) => { + var str = ''; + + str += props.size+'px'; + str += ' | '; + str += props.width; + + return str; + }, + preview: (classesMap) => { + var holderStyle = { + height: 50, + position: 'relative' + }; + var style = { + position: 'relative', + top: '50%', + transform: 'translateY(-50%)' + }; + + return ( +
    +
    +
    +
    +
    + ); + } +}; diff --git a/lib/components/elements/music-player.jsx b/lib/components/elements/music-player.jsx new file mode 100644 index 000000000..8126a3566 --- /dev/null +++ b/lib/components/elements/music-player.jsx @@ -0,0 +1,303 @@ +import React from 'react'; +import Component from '../component'; +import Element from '../element'; + +import {Types} from '../../types'; +import $ from 'jquery'; +import {soundManager} from 'soundmanager2'; + +import classNames from 'classnames'; +import jss from '../../react-jss'; + +const consumer_key = '6c786345f5161898f1e1380802ce9226'; + +export default class MusicPlayer extends Component { + + getInitialState () { + if (!this.context.editing && this.isClient()) { + if (this.props.type === 'soundcloud') { + this.loadSoundcloud(); + } else { + + } + } + + return { + playing: false, + loadedPercentage: 0, + loadedLabel: '00:00', + playedPercentage: 0, + playedLabel: '00:00' + }; + } + + componentWillUnmount () { + if (this.sound) { + this.sound.destruct(); + } + } + + loadSoundcloud () { + $.getJSON("http://api.soundcloud.com/resolve?url=" + this.props.soundcloud + "&format=json&consumer_key=" + consumer_key + "&callback=?", this.soundcloudLoaded.bind(this)); + } + + soundcloudLoaded (soundcloudInfo) { + this.url = soundcloudInfo.stream_url; + + if (this.url.indexOf('secret_token') === -1) { + this.url += '?'; + } else { + this.url += "&"; + } + + this.url += 'consumer_key=' + consumer_key; + soundManager.onready(this.createSound.bind(this)); + } + + createSound () { + this.sound = soundManager.createSound({ + id: 'sound_'+this.props.element.id, + url: this.url, + autoLoad: false, + autoPlay: false, + onfinish: this.playingStatusChanged.bind(this), + whileloading: this.whileLoading.bind(this), + whileplaying: this.whilePlaying.bind(this), + volume: this.props.defaultVolume + }); + + this.playingStatusChanged(); + //this.volumeChanged(); + } + + whileLoading () { + var loadedPercentage = this.sound.bytesLoaded / this.sound.bytesTotal; + + var secondsPassed = Math.round(this.sound.duration/1000); + var minutesPassed = 0; + if(secondsPassed >= 60){ + minutesPassed = Math.floor(secondsPassed/60); + secondsPassed = secondsPassed - minutesPassed*60; + } + var loadedLabel = (minutesPassed < 10 ? "0"+minutesPassed : minutesPassed) + ":" + (secondsPassed < 10 ? "0"+secondsPassed : secondsPassed); + + this.setState({ + loadedPercentage, + loadedLabel + }); + } + + whilePlaying () { + var playedPercentage; + if (this.sound.loaded) { + playedPercentage = this.sound.position / this.sound.duration; + } else { + playedPercentage = this.sound.position / this.sound.durationEstimate; + } + + var secondsPassed = Math.round(this.sound.position/1000); + var minutesPassed = 0; + if (secondsPassed >= 60) { + minutesPassed = Math.floor(secondsPassed/60); + secondsPassed = secondsPassed - minutesPassed*60; + } + var playedLabel = (minutesPassed < 10 ? "0"+minutesPassed : minutesPassed) + ":" + (secondsPassed < 10 ? "0"+secondsPassed : secondsPassed); + + this.setState({ + playedPercentage, + playedLabel + }); + } + + playingStatusChanged () { + if (this.sound.paused || this.sound.playState === 0) { + this.setState({ + playing: false + }); + } else { + this.setState({ + playing: true + }); + } + } + + togglePlay (event) { + event.preventDefault(); + + this.sound.togglePause(); + this.playingStatusChanged(); + } + + renderControls () { + var icon = this.state.playing ? 'fa fa-pause' : 'fa fa-play'; + return ( +
    + + + +
    + ); + } + + renderProgressBar () { + return ( +
    +
    +
    +
    + ); + } + + renderPlayback () { + return ( +
    +
    {this.props.artist}
    +
    {this.props.title}
    +
    + {this.state.playedLabel} +
    + {this.renderProgressBar()} +
    + {this.state.loadedLabel} +
    +
    + ); + } + + renderVolume () { + return ( +
    + +
    + ); + } + + render () { + return ( + + {this.renderControls()} + {this.renderPlayback()} + {this.renderVolume()} + + ); + } +} + +var classes = jss.createRules({ + musicPlayer: { + position: 'relative', + backgroundColor: '#333333' + }, + part: { + display: 'table-cell', + verticalAlign: 'middle' + }, + fit: { + width: '1%', + whiteSpace: 'nowrap' + }, + bar: { + position: 'relative', + height: 7, + backgroundColor: '#cccccc' + }, + streamBars: { + position: 'absolute', + top: 0, + left: 0, + width: 0 + } +}); + +MusicPlayer.propTypes = { + artist: React.PropTypes.string.isRequired, + title: React.PropTypes.string.isRequired, + type: React.PropTypes.oneOf(['local', 'soundcloud']).isRequired +}; + +MusicPlayer.defaultProps = { + artist: 'Artist/Band name', + title: 'Song title', + type: 'local', + defaultVolume: 50 +}; + +MusicPlayer.propsSchema = [ + { + label: 'Music', + type: Types.Select, + id: 'type', + props: { + labels: ['Your Sounds', 'Soundcloud'], + values: ['local', 'soundcloud'] + }, + unlocks: { + local: [ + + ], + soundcloud: [ + { + label: 'Soundcloud music url', + type: Types.String, + id: 'soundcloud' + } + ] + } + }/*, + { + label: 'Style', + type: Types.Style, + id: 'style', + props: { + type: 'musicPlayer', + options: [ + { + label: 'Toggle Play Button', + id: 'togglePlayButton', + type: Types.Group, + props: { + options: [ + + ] + } + } + { + label: 'Font Family', + id: 'font', + type: Types.Font + }, + { + label: 'Font Size', + id: 'fontSize', + type: Types.Pixels + }, + { + label: 'Line Height', + id: 'lineHeight', + type: Types.Pixels + }, + { + label: 'Color', + id: 'color', + type: Types.Color + } + ], + defaults: { + font: {}, + fontSize: 16, + lineHeight: 16, + color: '#ffffff' + } + } + }*/ +]; + +MusicPlayer.settings = { + icon: { + class: 'fa fa-music', + content: '' + }, + category: 'media', + drop: false, + drag: {} +}; diff --git a/lib/components/elements/schema.jsx b/lib/components/elements/schema.jsx new file mode 100644 index 000000000..07f639b7a --- /dev/null +++ b/lib/components/elements/schema.jsx @@ -0,0 +1,164 @@ +import React from 'react'; +import Component from '../component'; +import {Types} from '../../types'; +import Element from '../element'; +import cloneDeep from 'lodash.clonedeep'; +import forEach from 'lodash.foreach'; + +import schemasStore from '../../client/stores/schemas'; +import schemaEntriesStoreFactory from '../../client/stores/schema-entries'; + +export default class Schema extends Component { + + getInitialModels () { + var models = {}; + + if (this.props.schema && this.props.schema.schema) { + models.schema = schemasStore.getModel(this.props.schema.schema); + } + + return models; + } + + componentWillReceiveProps (nextProps) { + if (nextProps.schema && nextProps.schema.schema !== this.props.schema.schema) { + this.setModels({ + schema: schemasStore.getModel(nextProps.schema.schema) + }); + } + } + + componentDidUpdate (prevProps, prevState) { + if ( + this.state.schema && this.state.schema.slug && ( + (!prevState.schema) || + ( prevState.schema && this.state.schema.slug !== prevState.schema.slug) + )) { + this.setCollections({ + entries: schemaEntriesStoreFactory(this.state.schema.slug).getCollection() + }); + } + } + + alterProps (children, entry) { + forEach(children, (element) => { + element.props = element.props || {}; + + forEach(this.props.schema.fields, (field, key) => { + if (field.link === element.id) { + if (field.prop === 'children') { + element.children = entry[key]; + } else { + element.props[field.prop] = entry[key]; + } + } + }); + + element.id = this.props.element.id + '.' + element.id; + + if (element.children instanceof Array && element.children.length > 0) { + this.alterProps(element.children, entry); + } + }); + } + + renderCover () { + if (this.context.editing) { + return ( +
    + ); + } + } + + renderEntry (entry) { + var schemaModuleClone = cloneDeep(this.props.element.children); + + if (this.props.schema && this.props.schema.fields) { + this.alterProps(schemaModuleClone, entry); + } + + return ( +
    + {schemaModuleClone.map(this.context.renderElement)} + {this.renderCover()} +
    + ); + } + + renderEntries () { + if ( + this.state.entries && + this.state.entries.length && + this.state.entries.length > 0 && + this.props.element.children && + this.props.element.children.length > 0 + ) { + return ( +
    + {this.state.entries.map(this.renderEntry, this)} +
    + ); + } + } + + renderTemplateModule () { + if (this.context.editing) { + var style = { + position: 'relative' + }; + return ( +
    + {this.renderContent()} +
    +
    + ); + } + } + + render () { + var props = { + tag: 'div', + element: this.props.element, + settings: this.constructor.settings + }; + + return ( + + {this.renderTemplateModule()} + {this.renderEntries()} + + ); + } +} + +Schema.contextTypes = { + renderElement: React.PropTypes.func.isRequired, + editing: React.PropTypes.bool.isRequired +}; + +Schema.propTypes = { + +}; + +Schema.defaultProps = { + +}; + +Schema.propsSchema = [ + { + label: 'Schema', + type: Types.SchemaLink, + id: 'schema' + } +]; + +Schema.settings = { + icon: { + class: 'fa fa-sitemap', + content: '' + }, + drop: { + customDropArea: true + }, + drag: {} +}; diff --git a/lib/components/elements/section/index.jsx b/lib/components/elements/section/index.jsx new file mode 100644 index 000000000..1f44a1b30 --- /dev/null +++ b/lib/components/elements/section/index.jsx @@ -0,0 +1,114 @@ +import React from 'react'; +import Component from '../../component'; +import Element from '../../element'; +import MediaImage from '../../image'; +import Utils from '../../../utils'; +import styles from '../../../styles'; + +import settings from './settings'; +import style from './style'; +import propsSchema from './props-schema'; + +export default class Section extends Component { + getInitialState () { + return { + mounted: false + }; + } + + componentDidMount () { + this.resize(); + } + + componentDidUpdate () { + this.resize(); + } + + resize () { + var dom = React.findDOMNode(this); + var rect = dom.getBoundingClientRect(); + + var width = Math.round(rect.right-rect.left); + var height = Math.round(rect.bottom-rect.top); + + if (this.state.width !== width || this.state.height !== height) { + this.setState({ + mounted: true, + width, + height + }); + } + } + + renderBackground () { + if (this.state.mounted && this.props.useBackgroundImage && this.props.backgroundImage && this.props.backgroundImage !== '') { + var style = { + position: 'absolute', + top: 0, left: 0, right: 0, bottom: 0, + overflow: 'hidden' + }; + var imageStyle= { + position: 'relative', + minWidth: '100%', + minHeight: '100%', + maxWidth: 'none' + }; + imageStyle.top = this.state.height * (this.props.vertical / 100); + imageStyle.left = this.state.width * (this.props.horizontal / 100); + Utils.translate(imageStyle, (-this.props.horizontal)+'%', (-this.props.vertical)+'%'); + + return ( +
    + +
    + ); + } + } + + render () { + let classMap = this.props.style && styles.getClassesMap(this.props.style); + let className = classMap && classMap.section || ''; + let classNameContent = classMap && classMap.content || ''; + + let props = { + tag: 'div', + style: { + position: 'relative' + }, + className, + settings: this.constructor.settings, + element: this.props.element + }; + + if (this.props.navigation && this.props.navigation !== '') { + props.id = this.props.navigation; + } + + return ( + + {this.renderBackground()} +
    + {this.renderContent()} +
    +
    + ); + } +} + +Section.propTypes = { + backgroundImage: React.PropTypes.string.isRequired, + vertical: React.PropTypes.number, + horizontal: React.PropTypes.number, + navigation: React.PropTypes.string +}; + +Section.defaultProps = { + backgroundImage: '', + vertical: 50, + horizontal: 50, + navigation: '' +}; + +styles.registerStyle(style); +Section.propsSchema = propsSchema; +Section.settings = settings; diff --git a/lib/components/elements/section/props-schema.js b/lib/components/elements/section/props-schema.js new file mode 100644 index 000000000..79677ee5d --- /dev/null +++ b/lib/components/elements/section/props-schema.js @@ -0,0 +1,32 @@ +import {Types} from '../../../types'; + +export default [ + { + label: 'Navigation ID', + type: Types.String, + id: 'navigation' + }, + { + label: 'Background Image', + type: 'Optional', + id: 'useBackgroundImage', + unlocks: [ + { + type: Types.Image, + id: 'backgroundImage', + unlocks: [ + { + label: 'Vertical position', + type: Types.Percentage, + id: 'vertical' + }, + { + label: 'Horizontal position', + type: Types.Percentage, + id: 'horizontal' + } + ] + } + ] + } +]; diff --git a/lib/components/elements/section/settings.js b/lib/components/elements/section/settings.js new file mode 100644 index 000000000..f84972073 --- /dev/null +++ b/lib/components/elements/section/settings.js @@ -0,0 +1,13 @@ +export default { + icon: { + class: 'material-icons', + content: 'view_day' + }, + category: 'structure', + style: 'section', + drop: { + rejects: 'Section', + customDropArea: true + }, + drag: {} +}; diff --git a/lib/components/elements/section/style.js b/lib/components/elements/section/style.js new file mode 100644 index 000000000..7247e5950 --- /dev/null +++ b/lib/components/elements/section/style.js @@ -0,0 +1,110 @@ +import {Types} from '../../../types'; +import Colors from '../../../colors'; + +export default { + type: 'section', + options: [ + { + label: 'Background Color', + type: Types.Select, + id: 'backgroundColor', + props: { + labels: ['Transparent', 'Color'], + values: ['transparent', 'color'] + }, + unlocks: { + color: [ + { + label: 'Background color', + type: Types.Color, + id: 'color' + } + ] + } + }, + { + label: 'Height', + type: Types.Select, + id: 'height', + props: { + labels: ['Auto', 'Strict Height'], + values: ['auto', 'strict'] + }, + unlocks: { + strict: [ + { + label: 'Percentage from viewport', + type: Types.Percentage, + id: 'heightPerc', + props: { + min: 0, + max: 200 + } + }, + { + label: 'Content vertical alignment', + type: Types.Percentage, + id: 'contentVertical' + } + ] + } + }, + { + label: 'Padding', + type: Types.Padding, + id: 'padding' + } + ], + defaults: { + backgroundColor: 'transparent', + color: { + value: '#ffffff', + opacity: 100 + }, + height: 'auto', + heightPerc: 100, + contentVertical: 50, + padding: '20px' + }, + rules: (props) => { + var rule = {}; + var contentRule = {}; + + if (props.backgroundColor === 'color') { + rule.backgroundColor = Colors.getColorString(props.color); + } + + if (props.height === 'strict') { + rule.height = props.heightPerc+'vh'; + contentRule.position = 'relative'; + contentRule.top = props.contentVertical+'%'; + contentRule.transform = 'translateY(-'+props.contentVertical+'%)'; + } + + rule.padding = props.padding; + + return { + section: rule, + content: contentRule + }; + }, + getIdentifierLabel: (props) => { + var str = ''; + + if (props.height === 'strict') { + str += props.heightPerc+'%'; + } else { + str += 'Auto'; + } + + str += ' | '; + + if (props.backgroundColor === 'color') { + str += Colors.getColorString(props.color); + } else { + str += 'transparent'; + } + + return str; + } +}; diff --git a/lib/components/elements/text-box/classes.js b/lib/components/elements/text-box/classes.js new file mode 100644 index 000000000..a1b2f53ad --- /dev/null +++ b/lib/components/elements/text-box/classes.js @@ -0,0 +1,27 @@ +import jss from '../../../react-jss'; + +const common = { + fontSize: 'inherit', + lineHeight: 'inherit', + letterSpacing: 'inherit', + fontFamily: 'inherit', + fontStyle: 'inherit', + fontWeight: 'inherit', + margin: 0, + padding: 0, + color: 'inherit' +}; + +export default jss.createRules({ + text: { + outline: 0, + border: 0, + p: common, + h1: common, + h2: common, + h3: common, + h4: common, + h5: common, + h6: common + } +}); diff --git a/lib/components/elements/text-box/index.jsx b/lib/components/elements/text-box/index.jsx new file mode 100644 index 000000000..a82ed144f --- /dev/null +++ b/lib/components/elements/text-box/index.jsx @@ -0,0 +1,98 @@ +import React from 'react'; +import Component from '../../component'; +import Element from '../../element'; +import styles from '../../../styles'; +import cx from 'classnames'; +import Editor from '../../medium-editor'; + +import settings from './settings'; +import style from './style'; +import classes from './classes'; +import propsSchema from './props-schema'; + +export default class TextBox extends Component { + + getStyle () { + let style = {}; + + if (this.props.usePadding) { + style.padding = this.props.padding; + } + if (this.props.useAlign) { + style.textAlign = this.props.textAlign; + } + + return style; + } + + renderContent () { + var classMap = (this.props.style && styles.getClassesMap(this.props.style)) || {}; + + let html = ''; + if ((!this.props.children || this.props.children === '') && this.context.editing && !this.props.selected) { + html = 'Double click to edit text'; + } else { + html = this.props.children; + } + + if (this.context.editing && this.props.selected) { + return ( + + ); + } else { + return ( +
    + ); + } + } + + render () { + var props = { + tag: 'div', + element: this.props.element, + settings: this.constructor.settings, + style: this.getStyle() + }; + + return ( + + {this.renderContent()} + + ); + } +} + +TextBox.contextTypes = { + editing: React.PropTypes.bool.isRequired, + elementContentChange: React.PropTypes.func.isRequired +}; + +TextBox.propTypes = { + selected: React.PropTypes.bool.isRequired, + padding: React.PropTypes.string.isRequired, + textAlign: React.PropTypes.string.isRequired +}; + +TextBox.defaultProps = { + padding: '0px', + textAlign: 'left' +}; + +TextBox.defaultChildren = 'Click to edit text'; + +styles.registerStyle(style); +TextBox.propsSchema = propsSchema; +TextBox.settings = settings; diff --git a/lib/components/elements/text-box/props-schema.js b/lib/components/elements/text-box/props-schema.js new file mode 100644 index 000000000..34e3b2987 --- /dev/null +++ b/lib/components/elements/text-box/props-schema.js @@ -0,0 +1,30 @@ +import {Types} from '../../../types'; + +export default [ + { + label: 'Padding', + type: 'Optional', + id: 'usePadding', + unlocks: [ + { + type: Types.Padding, + id: 'padding' + } + ] + }, + { + label: 'Alignment', + type: 'Optional', + id: 'useAlign', + unlocks: [ + { + type: Types.Select, + id: 'textAlign', + props: { + labels: ['Left', 'Center', 'Right'], + values: ['left', 'center', 'right'] + } + } + ] + } +]; diff --git a/lib/components/elements/text-box/settings.js b/lib/components/elements/text-box/settings.js new file mode 100644 index 000000000..de1bb414d --- /dev/null +++ b/lib/components/elements/text-box/settings.js @@ -0,0 +1,11 @@ +export default { + icon: { + class: 'fa fa-font' + }, + category: 'content', + style: 'text', + drop: false, + drag: { + dragSelected: false + } +}; diff --git a/lib/components/elements/text-box/style.js b/lib/components/elements/text-box/style.js new file mode 100644 index 000000000..1ae053b93 --- /dev/null +++ b/lib/components/elements/text-box/style.js @@ -0,0 +1,114 @@ +import React from 'react'; +import Utils from '../../../utils'; +import Colors from '../../../colors'; +import {Types} from '../../../types'; + +export default { + type: 'text', + options: [ + { + label: 'Font Family', + id: 'font', + type: Types.Font + }, + { + label: 'Font Size', + id: 'fontSize', + type: Types.Pixels + }, + { + label: 'Line Height', + id: 'lineHeight', + type: Types.Pixels + }, + { + label: 'Letter Spacing', + id: 'letterSpacing', + type: Types.Pixels + }, + { + label: 'Color', + id: 'color', + type: Types.Color + }, + { + label: 'Links underline', + id: 'linkUnderline', + type: Types.Boolean + }, + { + label: 'Links color', + id: 'linkColor', + type: Types.Color + }, + { + label: 'Links color hover', + id: 'linkColorOver', + type: Types.Color + } + ], + defaults: { + font: {}, + fontSize: 16, + lineHeight: 16, + letterSpacing: 0, + color: { + value: '#ffffff', + opacity: 100 + }, + linkUnderline: true, + linkColor: { + value: '#ffffff', + opacity: 100 + }, + linkColorOver: { + value: '#ffffff', + opacity: 100 + } + }, + rules: (props) => { + var rule = {}; + rule.fontSize = props.fontSize+'px'; + rule.lineHeight = props.lineHeight+'px'; + rule.color = Colors.getColorString(props.color); + rule.letterSpacing = props.letterSpacing+'px'; + + if (props.font && props.font.family && props.font.fvd) { + rule.fontFamily = props.font.family; + Utils.processFVD(rule, props.font.fvd); + } + + // links + rule.a = { + textDecoration: props.linkUnderline ? 'underline' : 'none', + color: Colors.getColorString(props.linkColor), + ':hover': { + color: Colors.getColorString(props.linkColorOver) + } + }; + + return { + text: rule + }; + }, + getIdentifierLabel: (props) => { + var variation = props.font && props.font.fvd && ' ' + props.font.fvd.charAt(1)+'00' || ''; + return (props.font && props.font.family || '') + variation; + }, + preview: (classesMap) => { + var holderStyle = { + height: 55, + lineHeight: '55px' + }; + var style = { + display: 'inline-block', + verticalAlign: 'bottom' + }; + + return ( +
    +
    month
    +
    + ); + } +}; diff --git a/lib/components/elements/video/index.jsx b/lib/components/elements/video/index.jsx new file mode 100644 index 000000000..238aab345 --- /dev/null +++ b/lib/components/elements/video/index.jsx @@ -0,0 +1,110 @@ +import React from 'react'; +import Component from '../../component'; +import Element from '../../element'; +import Utils from '../../../utils'; + +import settings from './settings'; +import propsSchema from './props-schema'; + +export default class Video extends Component { + getInitialState () { + this.onResizeBind = this.onResize.bind(this); + return { + mounted: false + }; + } + + componentDidMount () { + window.addEventListener('resize', this.onResizeBind); + this.onResize(); + } + + onResize () { + var dom = React.findDOMNode(this); + var rect = dom.getBoundingClientRect(); + + var width = Math.round(rect.right-rect.left); + + this.setState({ + mounted: true, + width + }); + } + + componentWillUnmount () { + window.removeEventListener('resize', this.onResizeBind); + } + + renderIframe () { + var height = 300; + if (this.state.width) { + height = Math.round(this.state.width * (this.props.videoHeight / 100)); + } + + if (this.props.videoId && this.props.videoId !== '') { + var src = ''; + + if (this.props.type === 'youtube') { + let parsedID = Utils.parseYoutubeURL(this.props.videoId); + src = 'http://www.youtube.com/embed/' + (parsedID || this.props.videoId); + } else if (this.props.type === 'vimeo') { + let parsedID = Utils.parseVimeoURL(this.props.videoId); + src = 'http://player.vimeo.com/video/' + (parsedID || this.props.videoId); + } else if (this.props.type === 'dailymotion') { + let parsedID = Utils.parseDailymotionURL(this.props.videoId); + src = 'http://www.dailymotion.com/embed/video/' + (parsedID || this.props.videoId); + } + + var iframe = ; + + if (this.context.editing) { + return ( +
    + {iframe} +
    +
    + ); + } else { + return iframe; + } + } else { + let style = { + height + }; + return ( +
    + +
    + ); + } + } + + render () { + var style = {}; + + return ( + + {this.renderIframe()} + + ); + } +} + +Video.contextTypes = { + editing: React.PropTypes.bool.isRequired +}; + +Video.propTypes = { + type: React.PropTypes.string.isRequired, + videoId: React.PropTypes.string.isRequired, + videoHeight: React.PropTypes.number.isRequired +}; + +Video.defaultProps = { + type: 'youtube', + videoId: '', + videoHeight: 56 +}; + +Video.propsSchema = propsSchema; +Video.settings = settings; diff --git a/lib/components/elements/video/props-schema.js b/lib/components/elements/video/props-schema.js new file mode 100644 index 000000000..7e56d53ab --- /dev/null +++ b/lib/components/elements/video/props-schema.js @@ -0,0 +1,26 @@ +import {Types} from '../../../types'; + +export default [ + { + label: 'Video Host', + type: Types.Select, + id: 'type', + props: { + labels: ['Youtube', 'Vimeo', 'Dailymotion'], + values: ['youtube', 'vimeo', 'dailymotion'] + } + }, + { + label: 'Video Id/Url', + type: Types.String, + id: 'videoId' + }, + { + label: 'Video Height', + type: Types.Percentage, + id: 'videoHeight', + props: { + max: 200 + } + } +]; diff --git a/lib/components/elements/video/settings.js b/lib/components/elements/video/settings.js new file mode 100644 index 000000000..1d48079c8 --- /dev/null +++ b/lib/components/elements/video/settings.js @@ -0,0 +1,9 @@ +export default { + icon: { + class: 'material-icons', + content: 'videocam' + }, + category: 'media', + drop: false, + drag: {} +}; diff --git a/lib/components/filter.jsx b/lib/components/filter.jsx new file mode 100644 index 000000000..7db3d72b2 --- /dev/null +++ b/lib/components/filter.jsx @@ -0,0 +1,83 @@ +import React from 'react'; +import {Component} from 'relax-framework'; +import {Router} from 'relax-framework'; +import A from './a'; +import Utils from '../utils'; +import merge from 'lodash.merge'; + +export default class Filter extends Component { + getInitialState () { + return { + search: (this.context.query && this.context.query.s) || '', + }; + } + + searchChange (event) { + this.setState({ + search: event.target.value + }); + } + + searchSubmit (event) { + event.preventDefault(); + + var query = merge({}, this.context.query || {}); + + if(this.state.search !== ''){ + merge(query, {search: this.props.search, s: this.state.search}); + } else { + delete query.search; + delete query.s; + } + + var url = Utils.parseQueryUrl(this.props.url, query); + + Router.prototype.navigate(url, {trigger: true}); + } + + renderSortButton (button, key) { + var props = { + className: 'button-filter' + }; + + var query = { + sort: button.property, + order: 'asc' + }; + if(this.context.query && this.context.query.sort && this.context.query.sort === button.property) { + props.className += ' active'; + + if(!this.context.query.order || this.context.query.order === 'asc'){ + query.order = 'desc'; + } + } + + props.href = Utils.parseQueryUrl(this.props.url, query); + + return ( + {button.label} + ); + } + + render () { + return ( +
    + Sort by: + {this.props.sorts.map(this.renderSortButton, this)} +
    + +
    +
    + ); + } +} + +Filter.propTypes = { + sorts: React.PropTypes.array.isRequired, + url: React.PropTypes.string.isRequired, + search: React.PropTypes.string.isRequired +}; + +Filter.contextTypes = { + query: React.PropTypes.object +}; diff --git a/lib/components/font-picker/dropdown.jsx b/lib/components/font-picker/dropdown.jsx new file mode 100644 index 000000000..eb5375267 --- /dev/null +++ b/lib/components/font-picker/dropdown.jsx @@ -0,0 +1,72 @@ +import {Component} from 'relax-framework'; +import React from 'react'; + +export default class Dropdown extends Component { + + getInitialState () { + return { + opened: false + }; + } + + onEntryClick (value, event) { + event.preventDefault(); + this.props.onChange(value); + } + + onEntryEnter (value) { + this.props.tempChange(value); + } + + onEntryLeave () { + this.props.tempRevert(); + } + + toggle () { + this.setState({ + opened: !this.state.opened + }); + } + + renderEntry (entry) { + return ( + + {entry.label} + + ); + } + + renderCollapsable () { + if (this.state.opened) { + return ( +
    + {this.props.entries.map(this.renderEntry, this)} +
    + ); + } + } + + render () { + return ( +
    + {this.renderCollapsable()} + + {this.props.label} + + +
    + ); + } +} + +Dropdown.propTypes = { + value: React.PropTypes.string.isRequired, + label: React.PropTypes.string.isRequired, + entries: React.PropTypes.array.isRequired, + onChange: React.PropTypes.func.isRequired, + tempChange: React.PropTypes.func.isRequired, + tempRevert: React.PropTypes.func.isRequired +}; diff --git a/lib/components/font-picker/index.jsx b/lib/components/font-picker/index.jsx new file mode 100644 index 000000000..a32b7c012 --- /dev/null +++ b/lib/components/font-picker/index.jsx @@ -0,0 +1,132 @@ +import {Component} from 'relax-framework'; +import React from 'react'; +import Font from '../font'; +import Utils from '../../utils'; +import Dropdown from './dropdown'; +import clone from 'lodash.clone'; +import forEach from 'lodash.foreach'; + +import settingsStore from '../../client/stores/settings'; + +export default class FontPicker extends Component { + + getInitialState () { + return { + data: {} + }; + } + + getInitialModels () { + return { + data: settingsStore.getModel('fonts') + }; + } + + getChangedValue (key, value) { + var newValue = clone(this.props.value || {}); + + newValue[key] = value; + + if (key === 'family') { + // check if current fvd exists + var family = value; + var fvds = this.state.data.value.fonts[family]; + + if (fvds.indexOf(newValue.fvd) === -1) { + newValue.fvd = fvds[0]; + } + } + + return newValue; + } + + onChange (key, value) { + var newValue = this.getChangedValue(key, value); + this.props.onChange(newValue); + this.setState({ + selected: newValue + }); + } + + tempChange (key, value) { + var newValue = this.getChangedValue(key, value); + this.props.onChange(newValue); + } + + tempRevert () { + this.props.onChange(this.state.selected); + } + + renderFont () { + if (typeof this.props.value === 'object' && this.props.value.family && this.props.value.fvd) { + return ( + + ); + } else { + return ( +

    No font selected yet

    + ); + } + } + + renderOptions () { + var families = [], fvds = []; + var value = this.props.value || {}; + + if (this.state.data.value && typeof this.state.data.value.fonts === 'object') { + forEach(this.state.data.value.fonts, (fvdsArray, family) => { + families.push({ + label: family, + value: family + }); + + if (value.family && value.family === family) { + forEach(fvdsArray, (fvd) => { + fvds.push({ + label: fvd, + value: fvd + }); + }); + } + }); + } + + return ( +
    + + + +
    + ); + } + + render () { + return ( +
    + {this.renderFont()} + {this.renderOptions()} +
    + ); + } +} + +FontPicker.propTypes = { + value: React.PropTypes.string.isRequired, + onChange: React.PropTypes.func.isRequired +}; diff --git a/lib/components/font.jsx b/lib/components/font.jsx new file mode 100644 index 000000000..3c83b7fee --- /dev/null +++ b/lib/components/font.jsx @@ -0,0 +1,28 @@ +import {Component} from 'relax-framework'; +import React from 'react'; +import Utils from '../utils'; + +export default class Font extends Component { + + render () { + + var style = this.props.style || {}; + style.fontFamily = this.props.family; + Utils.processFVD(style, this.props.fvd); + + var content = ''; + + if(this.props.input) { + content = ; + } + else { + content =
    {this.props.text}
    ; + } + + return content; + } +} + +Font.propTypes = { + input: React.PropTypes.bool +}; diff --git a/lib/components/html.jsx b/lib/components/html.jsx new file mode 100644 index 000000000..6f2a8d666 --- /dev/null +++ b/lib/components/html.jsx @@ -0,0 +1,41 @@ +import React from 'react'; + +export default class Html extends React.Component { + renderTag (tag) { + tag.props = tag.props || {}; + if(tag.content){ + tag.props.dangerouslySetInnerHTML = {__html: tag.content}; + } + return ( + + ); + } + + renderHeader () { + if(this.props.props && this.props.props._locals && this.props.props._locals.header){ + return this.props.props._locals.header.map(this.renderTag, this); + } + } + + renderFooter () { + if(this.props.props && this.props.props._locals && this.props.props._locals.footer){ + return this.props.props._locals.footer.map(this.renderTag, this); + } + } + + render () { + return ( + + + {this.renderHeader()} + + + +
    +